Artharos / discord-music-bot-etherias

0 stars 0 forks source link

the bot is not joining voice channel #1

Open Artharos opened 2 years ago

Artharos commented 2 years ago

import discord from discord.ext import commands import youtube_dl

class music(commands.Cog): def init(self, client): self.client = client

@commands.command() async def join(self,ctx): if ctx.author.voice is None: await ctx.send("you're not in a voice channel") voice_channel = ctx.author.voice.channel if ctx.voice_client is None : await voice_channel.connect() else : await ctx.voice_client.move_to(voice_channel)

@commands.command() async def disconnect(self,ctx): await ctx.voice_client.disconnect()

@commands.command() async def play(self,ctx,url): ctx.voice_client.stop() FFMPEG_OPTION = {'before_option':'-reconnect 1 reconnect_streamed 1 -reconnect_delay_max 5', 'options':'-vn'} YDL_OPTIONS = {'format':"bestaudio"} vc = ctx.voice_client

with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
  info = ydl.extract_info(url, download=False)
  url2 = info['formats'][0]['url']
  source = await discord.FFmpegOpusAudio.from_probe(url2,**FFMPEG_OPTIONS)
  vc.play(source)

@commands.command() async def pause(self,ctx): await ctx.voice_client.pause await ctx.send("Paused :pause_button:")

@commands.command() async def resume(self,ctx): await ctx.voice_client.pause await ctx.send("resume :play_pause: ")

def setup(client): client.add_cog(music(client))

Artharos commented 2 years ago

import discord import os from keep_alive import keep_alive import random import discord.ext from discord.ext import commands import music

cogs = [music]

client = commands.Bot(command_prefix='$', intents=discord.Intents.all())

for i in range(len(cogs)): cogs[i].setup(client)

nexo = [ "meilleur dj incomming", "Le portugais est dans la place", "turbo Chiron online", "Bande de pignouf jvais vous buter", "8.6 forever" ]

client = discord.Client()

@client.event async def on_ready() : print('We have logged in as {0.user}'.format(client))

@client.event async def on_message(message) : if message.author == client.user: return

if message.content.startswith('$test'): await message.channel.send('test bon')

if message.content.startswith('$N3xo'): await message.channel.send(random.choice(nexo))

if message.content.startswith('$Draco'): await message.channel.send('Go le ban')

my_secret = os.environ['Token']

keep_alive() client.run(os.getenv('Token'))