Can you check if a message is a response to a wait_for coroutine in pycord - discord

My bot is meant to mimic social media posts within a server. It sends a certain webhook embed post every time there's a message in a particular channel (on_message).
The webhook embed post has buttons such as "share". When a user clicks that button, the bot awaits their next message in the channel to send a different type of embed post. However, because the bot is already posting off of every message event, both functions go off, sending both posts. Is there a way for the bot to detect or check for if the message sent after hitting "share" is fulfilling the "share" function's wait_for coroutine, so it knows not to double-post (i.e. not have the first event go off)? Or some other way?
I know that the easiest way to do this would be to have it as a command of some sort, but I want there to be limited chances for a user to mess up when it comes to "post"ing so that no messages in those channels are default (normal) messages, only the "platform" messages.
A snippet of my code is here: https://pastebin.com/Z8VNUHQQ
Relevant lines:
39- comment = await bot.wait_for(event='message', check=check)
90- async def on_message(message)

Related

Add Delay on each message box send by the "bot" in Twilio WebChat React workspace

Im using this workspace https://github.com/twilio/twilio-webchat-react-app that is connect with studio. I would like to know how can i apply delay on each message displayed in the chat via code, i tried several ways to apply delay, and i applied delay, but only when the "bot" send one message, the issue is that when the bot send more than one message, the delay is aplied in all the message instead os each message at a time. Is there a certain place that i have to put a setTimeout for each time that the Array of message push a message?
I know that i can put delay in studio with the Widget run function, but in a huge flow with many send messages to be delayed, would take a lot of time to make the connections and a lot more β€œmess” to deal, and by code would be much more practical.
I was working on these files: MessageBubble.tsx and MessageList.tsx.
I tried to put an boolean variable on a setTimeout if the message has an attribute 'delay' would be true and after the timeout would change to false, and according to that variable the display os the MessageBubble would be conditioned by this variable, but only applies when its only one message, not an group of send messages, if its a group, the display would be delayed, but when the display change to 'flex' it shows all the group of messages that the bot sent instaed of each message at a time.

Discord.py adding reaction to webhook.send message

I am able to send messages to my discord channel via webhook very easily, however, when trying to add reactions to the messages it's very difficult, considering my programming is still trivial.
The code line I have right now is:
data_count=1
webhook.send(content=discord.Reaction(message="test", data=data_count, emoji="πŸ‘"), file=discord.File("american_eagle_excited.gif"), embed=discord.Embed(title="Sample Embed", description="This is the description"))
Everything, when I break down the parameters I can get to work besides the discord.Reaction class. I feel like I am missing something very easily and after trying to read through the class requirements I had to finally make my way to StackOverflow.
To add a reaction you need the discord.Message instance which is returned by the webhook.send method, you then add the reaction with message.add_reaction
message = webhook.send("test", wait=True, ...) # `wait=True` is really important, if we don't set this the bot will not wait for the message to be returned
await message.add_reaction("πŸ‘")

Discord bot that moves people based on game activity

Hello everyone I'm new to coding but I want to code the bot mentioned in the title so my questions are:
-Is there a command that reads the game activity?
-What is the command that makes the bot move someone?
I set the basics up but don't really know where to go from here:
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Online');
});
client.login('*the token*');
All of a user's game activities are stored as an array, activities, within the presence property of your user object.
For example, if you want to get the game statuses of the author of a message, you can use <message>.author.presence.activities to get that array. However, since a user may have multiple statuses (custom statuses, games, Rich Presences, etc), you'll generally want to get a specific activity.
If you need to check if the name of the status is a certain one, you'll need to get the specific index first, such as <message>.author.presence.activities[0].name. If you want to check each status and see if any of them align with a needed name, you can use a for...of loop.
For more information, here is the documentation on the presence of a user.
As for "moving someone," you are not giving any more explanation as to what you mean, so that should be implemented once your bot can properly detect certain games.
In the meantime, try following a guide on how to turn user input into actual commands, and then this may make more sense if you are still facing issues.

How would you get reference to a dm channel by just the user?

I have a mod mail bot that went down for a few hours, so I want to fetch all the dms the bot received while it was down.
I have tried looping through all the members and checking the .dmChannel property but since it's cache based, it doesn't work
So the next step would be to fetch the channel, but you need the ID to do so, and I haven't found a way to get that.
I thought of using .send() on the members which would give me the channel object but it would probably annoy a lot of them.
So is there any other way to get reference to a user's dm channel which isn't cached?
You can use User.createDM to create a DM channel with them if you don't have one already:
const dmchannel = await user.createDM();

Show facebook chat bot has seen message

How can I send a facebook messenger response that acknowledges seeing the input but does not deliver a message?
Use Case:
I am attempting to improve my chat bot by better handling of multiple rapid inputs.
For example:
User: Order a pizza.
Bot: What toppings would you like?
User: cheees
User: cheese
It usually happens if the user misspelled a word and quickly sends a corrected spelling as in the example.
The bot currently processes the first input of cheees and prepares a response.
Then processes the second input of cheese as if it is an answer to the undelivered response.
So I am detecting if a second input is received before delivering the first in order to cancel that response, but I want to at least show that the first input was seen while waiting for the second input's response to be delivered.
It's definitely possible. There are sender actions. You're looking for mark_seen what exactly makes messages being seen by your bot.
I would have several recommendations here:
Always mark messages as seen. From the user perspective it shows that there is someone on the other side.
Prior to sending a message, you should consider sending a typing indicator for a second. This is how the user is used to see chat with his friends.
You could also wait one or two seconds before processing the user input if you receive something else.
We've build in these solutions into Amio Bot Builder. Feel free to use it or copy it.

Resources