【问题标题】:How can I make a welcome bot with json? Discord.py如何使用 json 制作欢迎机器人?不和谐.py
【发布时间】:2020-06-12 00:16:58
【问题描述】:

我希望每个服务器都设置自己的频道!我想知道是否有一种方法可以存储在频道中,以便每个服务器都有自己的欢迎频道!有人能弄清楚吗?

这是我当前的代码:

import discord
from discord.ext import commands

#Client
client = discord.Client()

#Prefix
client = commands.Bot(command_prefix = '!')

x = 'welcome'

#Custom Status
@client.event
async def on_ready():
    print("The bot is ready!")

async def welcomechannel(self, ctx):

    msg = ctx.message.content


async def on_member_join(member):
    channel = discord.utils.get(member.guild.channels, name=x)
    await channel.send("Test")




client.run('MY TOKEN')

【问题讨论】:

  • 您需要创建一个设置欢迎频道的命令。然后您需要将该信息保存在某处,例如在一个json中。信息将是公会 ID 和欢迎频道 ID。您需要从公会 ID 和频道 ID 检索信息并创建文本频道对象,然后将您的欢迎消息发送到那里。当你被困在一个特定的步骤时,回来问一个特定的问题。

标签: python discord discord.py


【解决方案1】:

我最近看了这个视频:https://www.youtube.com/watch?v=Y9DzfPJsP2s

Witch 解释了有关数据库和保存每个服务器的配置的所有内容!

【讨论】:

    猜你喜欢
    • 2021-04-27
    • 2021-04-19
    • 2021-03-31
    • 2020-10-08
    • 1970-01-01
    • 2021-04-08
    • 2020-06-20
    • 2021-07-07
    • 2019-01-21
    相关资源
    最近更新 更多