【发布时间】:2023-01-17 17:21:42
【问题描述】:
一段时间以来,我一直在为我所在的社区构建一个 discord.py 机器人。目前我正在处理各种“邮件列表”,如果我运行特定命令,机器人会向(当前)硬编码列表中的每个人发送一条消息。
这是我的代码。
#imports
import discord
import json
#takes token form config
with open("./config.json") as config:
configData = json.load(config)
token = configData["Token"]
#discord intents
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = discord.Client(intents=intents)
#login
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
list = ["12345678910","111213141516171819"]
#defining dm function
def dm_function():
for user in list:
user.send("test")
#makes and sends an embed to the channel command was used in and send the dm:s
@client.event
async def on_message(message):
if message.content.startswith('!testing'):
#embed stuff
#logins to bot with config.json
client.run(token)
dm:s 保持为空,而不是在 dm 中发送任何内容。 (机器人只发送嵌入。)
【问题讨论】:
标签: python discord discord.py