简体   繁体   English

如何让我的 discord 机器人获取所有服务器中的所有文本通道 ID?

[英]How do I make my discord bot get all text channel id's in all servers?

I basically want the bot to get the channel ID of all text channels in all servers.我基本上希望机器人获取所有服务器中所有文本频道的频道 ID。 I've looked for multiple hours but I can't seem to find anything.我已经找了几个小时,但我似乎找不到任何东西。 I'm guessing it would look something like this:我猜它看起来像这样:

for server in bot.guilds:
    for channel in server.channels(Channeltype=text)
        print(channel.id)

discord.Guild has an attribute called text_channels . discord.Guild有一个名为text_channels的属性。

for guild in bot.guilds:
    for text_ch in guild.text_channels:
        print(text_ch.id)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让我的 discord.py 机器人对频道中发送的所有图像做出反应 - How do i make my discord.py bot react to all images sent in a channel 如何让我的机器人从用户运行命令的位置获取通道 ID? (不和谐.py) - How do I make my bot get the channel Id from where the user ran the command from? (Discord.py) 如何让我的 Discord Bot 删除频道中的所有消息? - How can I make my Discord Bot delete all messages in a channel? 如何使用 discord.py 制作一个检查某个服务器通道中所有消息的机器人 - How do I use discord.py to make a bot that checks through all messages in a certain server channel 我可以让我的 discord 机器人向所有添加了机器人的服务器发送消息吗? - Can I make my discord bot send a message to all servers that has the bot added to it? Discord Python-如何使BOT声明频道的所有消息? - Discord Python - How to make the BOT say all the messages of a channel? (discord.py) 如何让我的机器人读取发送给它的 DM 并打印它们或将它们发送到特定频道 - (discord.py) How do I get my bot to read DM's that are sent to it and either print them or send them to a specific channel 我如何让不和谐机器人检查你是什么服务器? - How do i make a discord bot check in what servers are you? 在我的discord机器人键入特定命令后,如何获得所有用户输入的字符串? - How do I get all user input as a string with my discord bot after they type a certain command? 如何获取我的 discord 机器人拥有的所有角色的列表? - How do I get a list of all the roles my discord bot has?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM