L
L
La_koko2022-02-14 07:24:37
Python
La_koko, 2022-02-14 07:24:37

A discord bot that replies to messages. Can you help?

6209da4d45c21664357212.png

Выйти должно так
<code lang="python">

import discord
import const
client = discord.Client()
@client.event
async def on_ready():
    print('Загрузился {0.user}'.format(client))

@client.event
async def on_message(message):
    msg = message.content.lower()
    msg_list = msg.split()
    find_inj = False
    channel = client.get_channel(942477085727916052)
    channel2 = client.get_channel(942624705779753071)
    role2 = discord.utils.get(message.author.guild.roles, id=942629048578871296)
    role = discord.utils.get(message.author.guild.roles, id=942629133236707358)
    for item in const.inj:
        if msg.find(item)>=0:
            find_inj = True
    if find_inj:
        if channel==message.channel:
            if role in message.author.roles:
                return
            else:
                await channel.send('!Ответ Принимаю')
                await message.author.add_roles(message.author.guild.get_role(898612321755230260))
                await message.author.add_roles(message.author.guild.get_role(942459316059897887))
                await channel2.send(f'Прочитайте закреплённое {message.author.mention}')
    find_meh = False
    for item in const.meh:
        if msg.find(item)>=0:
            find_meh = True
    if find_meh:
        if channel==message.channel:
            if role2 in message.author.roles:
                return
            else:
                await channel.send('!Ответ Принимаю')
                await message.author.add_roles(message.author.guild.get_role(898612403284086784))
                await message.author.add_roles(message.author.guild.get_role(942459495903264869))
                await channel2.send(f'Прочитайте закреплённое {message.author.mention}')



client.run(const.TOKEN)
</code>
Необходимо вставить так чтобы сообщение "!Ответ Принимаю" отвечало на то, что его вызвало

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shandy, 2022-02-18
@MrShandy

If you need to send a message !Ответ Принимаюto a specific channel (regardless of the channel in which the command was called), then this will not work. Otherwise use await ctx.reply()
https://discordpy.readthedocs.io/en/latest/ext/com...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question