【发布时间】: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