是否可以不必添加频道ID就获得频道ID。还是可以在不指定频道的情况下使用bot.send_message?
public class NfseWSServiceStub extends org.apache.axis2.client.Stub {
}
我真的不想拥有@bot.event
async def on_member_join(member): # Member Join - Added 5 Oct
print (member, " joined")
embed = discord.Embed(title=":wave: {} just joined the server!".format(member.name), description="Welcome!", color=0x00ff00)
embed.set_thumbnail(url=member.avatar_url)
await bot.send_message(bot.get_channel(channelid), embed=embed)
,因为如果我想在其他服务器上使用该漫游器,则必须更改我的channelid变量,因此也可以一次将我的漫游器放置在两个服务器上。 / p>
答案 0 :(得分:0)
当然,要获取具有特定名称的频道,只需使用discord.utils.get
@bot.event
async def on_member_join(member): # Member Join - Added 5 Oct
server = member.server
print (member, " joined")
embed = discord.Embed(title=":wave: {} just joined the server!".format(member.name), description="Welcome!", color=0x00ff00)
embed.set_thumbnail(url=member.avatar_url)
try:
await bot.send_message(discord.utils.get(server.channels, name = "channel_name"), embed=embed)
except discord.InvalidArgument:
print("Channel doesn't exist")
在最后一部分中,您可以让漫游器创建频道(如果该频道不存在)而不是打印到控制台上
try:
await bot.send_message(discord.utils.get(server.channels, name = "channel_name"), embed=embed)
except discord.InvalidArgument:
await bot.create_channel(server, "channel_name", type=discord.ChannelType.text)
await bot.send_message(discord.utils.get(server.channels, name = "channel_name"), embed=embed)