Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Discord 不和谐的自我_Discord - Fatal编程技术网

Discord 不和谐的自我

Discord 不和谐的自我,discord,Discord,所以我有一个不和谐的自我机器人。基本上,它只是检查当服务器中的一个人说“@here”时,它会用我选择的消息尽快自动对他们进行dm。我只是想知道,如果有人说@here更快,我该如何进行自我机器人检查。你说的“更快”是什么意思?这是一种检查消息的方法,速度是if语句的两倍。据我所知,搜索字符串(你的代码有)的时间复杂度不会比O(n)高。也。 from discord.ext.commands import Bot from discord.ext import commands import asy

所以我有一个不和谐的自我机器人。基本上,它只是检查当服务器中的一个人说“@here”时,它会用我选择的消息尽快自动对他们进行dm。我只是想知道,如果有人说@here更快,我该如何进行自我机器人检查。

你说的“更快”是什么意思?这是一种检查消息的方法,速度是if语句的两倍。据我所知,搜索字符串(你的代码有)的时间复杂度不会比O(n)高。也。
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio

#TOKEN
TOKEN = "token"

client = discord.Client()
b = Bot(command_prefix = "!")

@b.event
async def on_ready():
    print("on")

@b.event
async def on_message(message):
    if "here" in message.content: 
        try:
            await message.author.dm_channel.send("Message I choose")
        except:
            print('The DM could not be send due to privacy permissions')

b.run(TOKEN, bot = False)