好的,所以我在 discord.py 中制作了一个程序,它接收收到的任何消息,如果该消息包含列表中的任何项目,它会发送一个 webhook。我以用户身份而不是机器人登录,因为我正在记录来自其他服务器的消息。当我运行我的程序时,它只记录我发送的消息。 我的代码:
import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions, CheckFailure, check
from discord_webhook import DiscordWebhook, DiscordEmbed
TOKEN_AUTH = "my token"
possible=['selling','Selling','SELLING']
client = discord.Client()
@client.event
async def on_ready():
print('hi')
@client.event
async def on_message(message):
for i in possible:
if i in message.content:
print('msg')
message.content = message.content.lower()
global response
global embed
global webhook
msgurl = message.jump_url
webhook = DiscordWebhook(url='mywebhook')
embed = DiscordEmbed(title=f'msg from {message.author}', description=f'{message.content}', color='03b2f8')
webhook.add_embed(embed)
response = webhook.execute()
webhook = DiscordWebhook(url=f'mywebhook', content=f'LINK TO MSG\n{msgurl}')
response = webhook.execute()
client.run(TOKEN_AUTH, bot=False)