如何将我的Discord机器人变成多个服务器机器人

发布于 2025-02-07 19:14:18 字数 799 浏览 2 评论 0原文

我做了一个不符合的机器人,它考虑了x和y之间的随机数,我使用了游戏标志(Ingame)来查看游戏是否已经启动,但是我现在有一个错误t开始游戏,因为服务器X启动。试图使用字典单独检查每个服务器,但实际上并不起作用。甚至在某人邀请机器人到服务器时添加行会名称,但它不起作用

games_in_progress = {}
@client.event
async def on_guild_join():
    server = guild.name
    print(server)
    games_in_progress[guild.name] = False
    print("Server added to the list")
global ingame
ingame = bool(True)

@client.command()
   guild = ctx.guild
   if guild not in games_in_progress:
       games_in_progress[guild] = True
   else:
       if guild == "True":
           await ctx.send("There is already a game in your server {}")
    if ingame == True:
       * do the code*
    else:
       await ctx.send("a game is already in progress, finish the game in {} to start a new 
       one!".format(gamechannel.mention))

I made a discord bot that thinks about a random number between X and Y and I used a game flag (ingame) to see if a game has already started or not but I have an error now that if server X started a game server Y can't start a game because server X started. Tried to use dictionaries to check each server individually but it doesn't really work. Even tried to add the guild name when someone invites the bot to the server but it didn't work aswell

games_in_progress = {}
@client.event
async def on_guild_join():
    server = guild.name
    print(server)
    games_in_progress[guild.name] = False
    print("Server added to the list")
global ingame
ingame = bool(True)

@client.command()
   guild = ctx.guild
   if guild not in games_in_progress:
       games_in_progress[guild] = True
   else:
       if guild == "True":
           await ctx.send("There is already a game in your server {}")
    if ingame == True:
       * do the code*
    else:
       await ctx.send("a game is already in progress, finish the game in {} to start a new 
       one!".format(gamechannel.mention))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文