Firstly to answer your question about default_channel
: Since about June 2017, discord no longer defines a "default" channel, and as such, the default_channel
element of a server is usually set to None.
Secondly, by saying discord.Server.default_channel
, you're asking for an element of the class definition, not an actual channel. To get an actual channel, you need an instance of a server.
Now to answer the original question, which is to send a message to every channel, you need to find a channel in the server that you can actually post messages in.
@bot.event
async def on_ready():
for server in bot.servers:
# Spin through every server
for channel in server.channels:
# Channels on the server
if channel.permissions_for(server.me).send_messages:
await bot.send_message(channel, "...")
# So that we don't send to every channel:
break
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…