You've used client
in some places and bot
in some other places, more over this code isn't very efficient as it's not required to iterate through the guilds when you're calling it from only one server, that would cause spam in multiple servers. I've also noticed you're using functions from an older version of discord.py
. Try using this instead:
@client.command()
async def broadcast(ctx, *, msg):
for channel in ctx.guild.text_channels:
try:
await channel.send(msg)
except:
continue
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…