gpt4 book ai didi

python - 使用列表随机向 channel 发送消息

转载 作者:行者123 更新时间:2023-12-01 01:19:07 25 4
gpt4 key购买 nike

我有一个 channel 列表和一个在 time.sleep 上运行的后台线程。我的目标是将随机消息从 list_of_msgs=[] 发送到来自 channel_list=[] 的随机 channel 。

这就是我填充 channel 列表的方式:

chan_list = []
for server in self.bot.servers:
for channel in server.channels:
if channel.type == discord.ChannelType.text:
chan_list.append(channel)
print(', '.join(map(str, chan_list))) ###for testing###

将 send_message 从列表发送到另一个列表上的 channel 的正确方法是什么?

最佳答案

import random
random.choice(chan_list)

你试过这个吗?

关于python - 使用列表随机向 channel 发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54015638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com