我刚接触过python和discord.py,很抱歉有任何混乱之处。因此,我试图为我的机器人制作一个modmail系统,但是据我的理解,似乎没有从dm获得服务器id的方法,或者类似的方法,但是如果bot位于多个服务器中,我如何确定要将消息发送到哪个服务器?我的想法是检查发送的消息,看看用户是否发送了服务器的id,但是我不认为我做得很好。
这是我目前所做的,它似乎很好,但只是从外观上,我知道它不可能是正确的。
@commands.Cog.listener()
async def on_message(self,message):
if not message.a
这是一个基本的想法-我不想要触发消息的作者,而是在触发消息的作者之前出现的消息。
希望举个例子,我的意思是:
初始消息:Author1: Foo
触发消息:Author2: That thing you said is cool
Bot的回应:Bot: @Author1 is cool!
显然,来自Author2的消息是什么触发了机器人,但是我如何让机器人找到前面消息的作者呢?到目前为止,我得到的是:
@commands.Cog.listener('on_message')
async def cool(self, message):
if me
我试图添加一个函数来检查用户在过去2天内发送的消息的数量,现在我正在遍历所有的通道历史并一次检查消息1,但是对于一个每天接收数千条消息的公会,这需要很长时间,有什么方法可以指定最大的回溯时间吗?
这是我的当前代码
# This is also inside of a cog
now = datetime.datetime.now()
joined_on = ctx.author.joined_at
delta = datetime.timedelta(joined_on, now)
if delta.days >= 2:
message = 0
for channel i
我正在使用Python3.9.6和Discord.py制作一个不和谐的机器人。我正在使用两个命令处理齿轮;一个用于从函数外部的列表中发送随机字符串,另一个用于将字符串添加到消息列表中。当我尝试传递消息变量时,似乎一切正常,但当我在不一致的情况下测试命令时,出现了以下错误消息: discord.ext.commands.errors.MissingRequiredArgument: messages is a required argument that is missing. 我认为这意味着机器人期望用户给出messages,所以我尝试删除messages参数。但是,当我这样做时,我得到了这
我知道我是新来的,但我有个问题要问你:
如果您想用Python编写一个带有特殊齿轮的不和谐的机器人,并用以下方式替换默认的help命令,该怎么办:
@commands.command(pass_context=True)
async def help(self,ctx,*cog:str):
"""Gives you info on my cogs *and* their commands."""
if not cog:
halp=discord.Embed(title='Cog Listing and Un
我尝试在我的cogs文件中实现嵌入消息。当我尝试使用该命令时,此错误在我的控制台上弹出。 An exception has occurred while executing command `cal`:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 1352, in invoke_command
await func.invoke(ctx, **args)
F
我试图从用户那里得到一条消息,然后将其发送到特定的文本频道。信息应嵌入其中。但是我不喜欢当您有一堆字段时,我希望discord.Embed()中的描述保存文本内容。但是它给了我一个错误TypeError: Object of type Message is not JSON serializable
这是我的密码:
class Changelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_r
我正在尝试创建一个不一致的帮助“日志”命令。
@client.command()
async def logs(ctx):
for channel in ctx.guild.channels:
if channel.name == "henry-logs":
await ctx.send("Henry Logs channel is already setup. If you have access to it, it should be available in the channel list")
else:
await ctx.s
我的代码:
@commands.Cog.listener()
async def on_message(self, message):
if message.author.id == self.bot.user.id:
return
if message.channel.type == discord.ChannelType.private:
await message.channel.send("Vous devez être dans un serveur pour realiser c
编辑:我终于让代码工作了,但只有一个频道。有没有办法让它变成两个频道?我试过做'or‘,但不起作用。它只接受一个通道,或者有时会忽略所有通道。
例如。删除所有用户消息并进行测试,但!ask或!every in general和!test in test除外
@commands.Cog.listener()
async def on_message(self, message):
if not message.guild:
return
if not message.channel.name == 'general':
re
设置:我制作了一个机器人来与服务器上的用户进行交互。我增加的一个特点是马可波罗的游戏。当用户发送"Marco“时,机器人会以”POLO.“作为响应。
问题:当机器人用“POLO.”进行响应时,它与原始消息在同一个通道上响应。但是,我希望bot在服务器内的随机通道中作出响应,这会让用户寻找它。
我在网上搜索过答案,也在discord.py上搜索过,但是我一直找不到答案。然而,我对Python和编码完全陌生,所以很可能我只是遗漏了一些东西,或者它是不可能的,LOL。
这是马可波罗游戏的代码:
@client.event
async def on_message(message):
if m
问题的措辞可能有些奇怪,但我正在尝试让一个函数将一个通道提到和一个消息(字符串)作为参数,然后将消息发送到所提到的通道。这个函数在一个类(cog)中,所以它有self
# Discord Imports
import discord
from discord.ext import commands
from discord.utils import get
class Author_Only(commands.Cog):
def __init__(self,bot):
self.bot=bot
@commands.command(
brief='Sends a