Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Music.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import pickle

# Intents and settings
# Voice state intent is required so the bot can join and manage voice channels
intents = discord.Intents.default()
intents.guilds = True
intents.message_content = True
intents.voice_states = True

Expand Down Expand Up @@ -73,10 +75,9 @@ async def play_next(self, ctx):
except Exception as e:
print(f"Error playing audio: {str(e)}")
await ctx.send(f"Error playing audio: {str(e)}")
elif not ctx.voice_client.is_playing():
elif ctx.voice_client and not ctx.voice_client.is_playing():
await ctx.send("Queue is empty!")
print("Queue is empty!")
await ctx.voice_client.disconnect()

@commands.command()
async def play(self, ctx, *, search):
Expand All @@ -85,7 +86,9 @@ async def play(self, ctx, *, search):
if not voice_channel:
return await ctx.send("You're not in a voice channel!")
if not ctx.voice_client:
await voice_channel.connect()
await voice_channel.connect(self_deaf=True)
elif ctx.voice_client.channel != voice_channel:
await ctx.voice_client.move_to(voice_channel)

async with ctx.typing():
try:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ For the correct installation of FFmpeg on Windows we suggest using the following

for the installation of the dependencies it is suggested to use pip install -r requirements

## Discord intents
Discord recently made voice state data a privileged intent. Make sure the bot token has the **Message Content** and **Voice State** intents enabled in the [Discord Developer Portal](https://discord.com/developers/applications) so commands like `!play` can join voice channels. Both `Music.py` and `index.py` already request these intents in code.

9 changes: 6 additions & 3 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
import openai


intents = discord.Intents.default()
intents.message_content = True
intents = discord.Intents.default()
intents.guilds = True
intents.message_content = True
# Voice state intent is required for connecting to and managing voice channels
intents.voice_states = True
openai.api_key = 'Token Chatgpt'

bot = commands.Bot(command_prefix="!", intents=intents)
Expand Down Expand Up @@ -332,4 +335,4 @@ async def chat(ctx, *, message: str):



bot.run('Token Discord')
bot.run('Token Discord')