hardrobic
Centipat
- Katılım
- 23 Ekim 2022
- Mesajlar
- 47
- Çözümler
- 3
Daha fazla
- Cinsiyet
- Erkek
Merhaba Discord müzik botu yapmak için uğraşıyorum. Botu Online yaptım ama şimdi '!play' komutuyla müzik çalıştırmak istiyorum ama herhangi bir şekilde botla etkileşime giremiyorum aşağıya kaynak kodunu bırakıyorum.
Python:
import discord.
import asyncio.
import youtube_dl.
from discord.ext import commands.
intents = discord.Intents.default()
intents.members = True.
bot = commands.Bot(command_prefix='!', intents=intents)
client = discord.Client(intents=discord.Intents.default())
players = {}
intents = discord.Intents.default()
intents.members = True.
def check_queue(id):
if players[id]["queue"]:
player = players[id]["queue"].pop(0)
players[id]["player"] = player.
player.start()
@bot.command(pass_context=True)
async def play(ctx, url: str):
author = ctx.message.author
voice_channel = author.voice.channel
vc = await voice_channel.connect()
player = await vc.create_ytdl_player(url, after=lambda: check_queue(author.guild.id))
if not author.guild.id in players:
players[author.guild.id] = {"player": None, "queue": []}
players[author.guild.id]["queue"].append(player)
if not players[author.guild.id]["player"]:
player.start()
await ctx.send(f"Enqueued {url}")
@bot.command(pass_context=True)
async def pause(ctx):
id = ctx.message.author.guild.id
players[id]["player"].pause()
@bot.command(pass_context=True)
async def resume(ctx):
id = ctx.message.author.guild.id
players[id]["player"].resume()
@bot.command(pass_context=True)
async def stop(ctx):
id = ctx.message.author.guild.id
players[id]["player"].stop()
@bot.command(pass_context=True)
async def skip(ctx):
id = ctx.message.author.guild.id
players[id]["player"].stop()
check_queue(id)
@bot.command(pass_context=True)
async def volume(ctx, volume: int):
id = ctx.message.author.guild.id
players[id]["player"].volume = volume / 100.
bot.run('tokenyerim')