【发布时间】:2021-03-10 03:03:38
【问题描述】:
我打算制作一个通用机器人,它也可以调用其他机器人。有什么想法吗?
import os
import discord
import time
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = commands.Bot(command_prefix = ".")
@bot.event
async def on_ready():
print(f"{bot.user.name} is ready")
#---------------------------------------#
@bot.command(name = "bot_interact")
async def join(ctx, voice_channel: commands.VoiceChannelConverter):
await voice_channel.connect()
await ctx.send("-play (desired_song)")
time.sleep(2)
await ctx.send("-loop")
@bot.command(name = "leave")
async def leave(ctx):
server = ctx.message.guild.voice_client
await server.disconnect()
#---------------------------------------#
bot.run(TOKEN)
此外,我把它写得太满了,所以你可以具体看到我想要做什么,这是我的机器人来引起 Groovy 的注意,并告诉 Groovy,我想播放这首歌。请记住,我对 python 比较陌生,我没有使用太多。提前谢谢
【问题讨论】:
-
大多数机器人不允许与其他机器人交互,我认为这是不可能的,尤其是在 Groovy 中。
标签: python discord.py