Ich habe bereits einen code, der nicht funktioniert:
Code: Alles auswählen
@commands.command()
async def hilfe(ctx):
await ctx.send('hi')
also soll er mit dem command "-hilfe" eine Nachricht senden
Code: Alles auswählen
@commands.command()
async def hilfe(ctx):
await ctx.send('hi')
Code: Alles auswählen
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("Du bist nicht in einem Sprachkanal")
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None:
await voice_channel.connect()
await ctx.send('Moin Meistä, was willst du hören?')
else:
await ctx.voice_client.move_to(voice_channel)
@commands.command()
async def leave(self,ctx):
await ctx.voice_client.disconnect()
await ctx.send('Alles klar! Bin weg.')
@commands.command()
async def play(self,ctx,url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
await ctx.send('Alles klar! Wird abgespielt.')
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 hilfe(self,ctx, *, user_message):
await ctx.send('h')
@commands.command()
async def stop(self,ctx):
await ctx.voice_client.stop()
await ctx.send('gestoppt')
@commands.command()
async def resume(self,ctx):
await ctx.voice_client.resume()
await ctx.send('Es geht weiter')
def setup(client):
client.add_cog(music(client))