My bot starts up fine and shows no errors but it completely ignores all commands like $connect, $disconnect, $start, etc. It also doesn’t respond to any events. Everything was working perfectly yesterday but now it’s broken.
import discord
from discord.ext import commands
from discord import FFmpegPCMAudio
from better_profanity import profanity
import random
import os
permissions = discord.Intents.all()
permissions.members = True
client = commands.Bot(command_prefix='$', intents=permissions)
import config as cf
import joke_fetcher as jf
@client.event
async def on_ready():
print("Bot is online and ready!")
@client.event
async def on_member_join(user):
welcome_channel = client.get_channel(1161221526150987807)
await welcome_channel.send(f"Welcome {user.display_name}! Glad to have you here!")
await welcome_channel.send(jf.joke_setup)
await welcome_channel.send(jf.joke_punchline)
@client.event
async def on_member_remove(user):
goodbye_channel = client.get_channel(1161221526150987807)
await goodbye_channel.send(f"See you later {user.display_name}!")
@client.event
async def on_message(msg):
responses = ['Watch your language!', 'That is not appropriate!', 'Please be respectful!']
if profanity.contains_profanity(msg.content):
await msg.delete()
await msg.channel.send(random.choice(responses))
@client.command()
async def connect(ctx):
if ctx.author.voice:
voice_channel = ctx.message.author.voice.channel
connection = await voice_channel.connect()
audio_source = FFmpegPCMAudio('welcome.mp3')
connection.play(audio_source, after=lambda x=None: process_queue(ctx, ctx.message.guild.id))
print('Connected to voice')
else:
await ctx.send('You need to be in a voice channel first!')
@client.command()
async def disconnect(ctx):
if ctx.voice_client:
await ctx.guild.voice_client.disconnect()
await ctx.send('Disconnected from voice channel!')
else:
await ctx.send('Not connected to any voice channel!')
@client.command()
async def halt(ctx):
connection = discord.utils.get(client.voice_clients, guild=ctx.guild)
if connection.is_playing():
connection.pause()
else:
await ctx.send('Nothing is currently playing!')
@client.command()
async def continue_play(ctx):
connection = discord.utils.get(client.voice_clients, guild=ctx.guild)
if connection.is_paused():
connection.resume()
else:
await ctx.send('Audio is not paused!')
@client.command()
async def terminate(ctx):
connection = discord.utils.get(client.voice_clients, guild=ctx.guild)
connection.stop()
play_queues = {}
def process_queue(ctx, guild_id):
if play_queues.get(guild_id):
if play_queues[guild_id] != []:
connection = ctx.guild.voice_client
next_audio = play_queues[guild_id].pop(0)
connection.play(next_audio)
@client.command()
async def start(ctx, filename):
connection = ctx.guild.voice_client
track_file = filename + '.mp3'
if not os.path.isfile(track_file):
await ctx.send('Cannot find that audio file.')
return
audio_source = FFmpegPCMAudio(track_file)
connection.play(audio_source, after=lambda x=None: process_queue(ctx, ctx.message.guild.id))
await ctx.send('Playing: ' + filename)
@client.command()
async def add_to_queue(ctx, filename):
connection = ctx.guild.voice_client
track_file = filename + '.mp3'
if not os.path.isfile(track_file):
await ctx.send('Cannot find that audio file.')
return
audio_source = FFmpegPCMAudio(track_file)
server_id = ctx.message.guild.id
if server_id in play_queues:
play_queues[server_id].append(audio_source)
else:
play_queues[server_id] = [audio_source]
await ctx.send(f'Queued {track_file}')
client.run(cf.token)
I tried regenerating the bot token, toggling all the gateway intents, making a completely new bot, and reinstalling discord.py. Nothing works even though it was fine yesterday with my custom modules!