A
A
Andrey Volchara2020-10-12 21:32:28
Python
Andrey Volchara, 2020-10-12 21:32:28

How to make the command work only in pm + log?

As planned, the bot should respond to the command that is sent to the PM. If the command is sent in a server channel - no response. In fact, the bot perceives the command both in LAN and in channels.
1. How to actually do so that the reaction to the command would be only in PM?
2. How to make a bot message log, for example, for 24 hours, in the form user/message?

@bot.command()
async def anon(ctx, *, arg):
    if discord.ChannelType.private:
    	channel = bot.get_channel(#id)
    	await channel.send(arg)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-10-13
@vollchara

1. https://discordpy.readthedocs.io/en/stable/ext/com...

@bot.command()
@commands.dm_only()
async def cmd(...):

2. https://discordpy.readthedocs.io/en/stable/api.htm...
https://discordpy.readthedocs.io/en/stable/api.htm...
https://discordpy.readthedocs. io/en/stable/api.htm...
isinstance(ctx.channel, discord.DMchannel)
# или
ctx.channel.type == discord.ChannelType.private

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question