Home>

I want to make it so that, for example, when you ping a bot on discord, it will send a message like "type .ban"

Where should he send this message?

V-Mor2022-02-14 12:30:49

in the same channel where he was pinged

Ginger2022-02-14 12:30:49

I don `t understand. By ping do you mean the ping utility in the classical sense or something else?

V-Mor2022-02-14 12:30:49

Ping is a discord functionality that allows you to send a request to a bot, for example, to check its performance. It has nothing to do with this utility.

BlueScreen2022-02-14 12:30:49
  • Answer # 1
    @bot.event
    async def on_message(message):
        if("<@!bot id>"in message.content):
            await message.channel.send('write .ban')
        await bot.process_commands(message)
    

    please try to leave a little more detailed answers. You can add to your answer by clicking edit.

    aleksandr barakin2022-02-13 22:32:26

    Well, at least the word boundary after id should be checked or something ...

    Qwertiy2022-02-14 01:08:59
  • Answer # 2
    @bot.event
    async def on_message(message):
        if("<@!bot id>"in message.content):
            await message.channel.send('write .ban')
        await bot.process_commands(message)
    

    please try to leave a little more detailed answers. You can add to your answer by clicking edit.

    aleksandr barakin2022-02-13 22:32:26

    Well, at least the word boundary after id should be checked or something ...

    Qwertiy2022-02-14 01:08:59
  • Answer # 3

    Opening off APIThey give an example of this code:

    @bot.command()
    async def ping(ctx):
        await ctx.send('Pong!\n Latency {0}'.format(round(bot.latency, 1)))
    

    Accordingly, in order for him to answer what you want, you need to:

    @bot.command()
    async def ping(ctx):
        await ctx.send("Type .ban")
    

    The quotation mark should be closed

    dIm0n2022-02-14 12:30:49

    closed, thanks

    BlueScreen2022-02-14 12:30:49

    There should be quotes of the same type :) Either only ' or only "

    dIm0n2022-02-14 12:30:49
  • Answer # 4

    Opening off APIThey give an example of this code:

    @bot.command()
    async def ping(ctx):
        await ctx.send('Pong!\n Latency {0}'.format(round(bot.latency, 1)))
    

    Accordingly, in order for him to answer what you want, you need to:

    @bot.command()
    async def ping(ctx):
        await ctx.send("Type .ban")
    

    The quotation mark should be closed

    dIm0n2022-02-14 12:30:49

    closed, thanks

    BlueScreen2022-02-14 12:30:49

    There should be quotes of the same type :) Either only ' or only "

    dIm0n2022-02-14 12:30:49