Making a verification bot in Discord.py - discord

I am in progress of making a Discord bot. I would like the bot to send a direct message to newly joined members including their username and avatar. Then finding if the account is too new, as an anti raiding system in my Bot.

Your criteria is not possible in Discord. Getting personal data (Users email address) from a Discord user is not possible what so ever. Discord would never let any user have access to private data in their API.
Fortunately, a much easier way of creating this is to check if the account was recently made. Using member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC")) will simply get the time and date the joined user created their account at. I'll leave it up to you when you want to set a threshold of how early a user can join.
You can also check when the user joined a server with, also remember to define the member as the Discord user who joined. I am leaving the rest for you to complete but hoping this helps get you farther in your progress. Next time, remember to include your trialed attempt and please don't always rely on the community to give you a whole code of answers.
member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))

Related

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.

Is it logical to invoke other intent from the custom intent in an Alexa app

My interaction has to be executed in two steps. in first step. Alexa will get some information to the user. On the basis of published information, Alexa will ask to take another action from the user's answer (Which is yes/no).
So is it possible to invoke one intent and on the basis of previous intent's reply through reprompt, i would be able to call another intent of alexa app.
if so, then how can i do that through akexa node js SDK v2.
Use Case:
My app is connecting with third party API which needs alexa to use Account Linking. Scenario is, when my account is linked and i have valid access token. Here's how conversation will go:
User: Alexa, ask "a" to get me overdue invoices.
Alexa: You have "x" number of invoices. Do you want to send payment reminders?
User: Yes.
Alexa: Your request to send reminders has been registered. Anything else I can help?
User: No Thanks.
So for this, I have to communicate with an external API two times. One, while getting overdue invoices, and two, while sending reminders.
From your example, I'm guessing you have invoices as one intent, then reminders as another intent. If reminders is only ever used immediately after invoices, then I'd make them a single intent. But if you want users to create reminders at any point, or if you have multiple intents that could flow into the reminders intent, then separate intents can work.
Check out:
How to Pass a new Intent
Each of the Dialog directives includes an updatedIntent property that can take an Intent object. Use this to:
Trigger a dialog on a completely different intent. For example, after completing the dialog for a BookFlight intent, you could return Dialog.Delegate with updatedIntent set to BookRentalCar to start new dialog.
...
When you use updatedIntent to change to a different intent, the directive acts against the new intent instead of the original:
...
When you use updatedIntent to set or change data on the original intent, make sure that the intent name and full set of slots matches the intent sent to your skill.
So to use your example, this is what you would do:
User: Alexa, ask SkillName to get me overdue invoices.
Trigger invoices intent.
Make API call, get # invoices.
Return Dialog.Delegate or Dialog.ElicitSlot or Dialog.ConfirmIntent with updatedIntent set to reminders intent. (include any and all slots, must be a full intent object)
Set the outputSpeech to "You have X number of invoices. Do you want to send payment reminders?"
Alexa: You have X number of invoices. Do you want to send payment reminders?
User: Yes.
Depending on which Dialog Directive you've chosen to use, it will return the user's answer differently. Either filling a slot you've prepared, or in a confirmationStatus, or AMAZON.YesIntent.
Check for the correct one of those, and make your reminders API call if confirmed.
Return fulfilled intent with output message:
Alexa: Your request to send reminders has been registered. Anything else I can help?

How do I make it so people can't vote twice on a Discord poll system?

I have a Discord Bot which has a poll system. The Discord bot can create multiple polls and store the data in a .json file. The only problem with this is people can vote twice for a single poll. How do I make it so a person can't vote twice for a single poll? This may seem like a simple question, however, I can't find a way to solve this.
Create an array in the JSON file called "voted" and whenever someone votes, add their Discord ID to the array. Whenever someone tries to vote, check if their ID already exists in the "voted" array.
NOTE: This will not prevent users from creating spam accounts just to vote.

IMAP - JavaMail - How to know which messages to process?

What I want to achieve:
I am coding a Java program that uses IMAP to connect to some gmail accounts every 5 minutes and extract information from some messages.
I want to check all the messages (incoming and outgoing) and take only the ones I have not processed. By "processed" I do not mean only "read" or "seen" messages. My application does not care whether or not another user has accessed that account and read a message. My application needs to keep track of which was the last message it processed and, the next time it goes through the messages, start with the first non-processed message.
I do not want to change anything in the messages. I do not want to mark them as seen or read.
What I have implemented:
Establish IMAP connection.
Open and access all messages in "[Gmail]/All Mail" folder.
What I have tried:
I have been reading about UID and message number, but I am not sure if any of them could help me achieve what I want. Maybe UID could, but: how do I retrieve it with JavaMail?
I found Folder.getMessages(int start, int end), but I think it refers to the index of the message in a folder, which I believe can easily change.
Can anyone provide some guidance at what is the best approach to take here?
Thanks!
IMAP UIDs are relative to the folder containing the message. I don't know how Gmail handles UIDs for messages in the "[Gmail]/All Mail" folder, but if it does the right thing you could use the UIDFolder interface to get the UIDs. And as described, once you've processed a certain UID, all the new messages will have larger UIDs, which can make processing more efficient.
The alternative is to use Message-IDs, which has a different set of problems...

Swipe-delete messages only for current user

thanks for taking time looking at my question.
Ok so I'm working on this iPhone app. I'm responsible for the server side code. Client side is asking for a solution to delete private messages from the app. I have created a HTTP DELETE for them that deletes a specific message. But this request deletes the message from the database and that makes the message disappear for both users and not only the one that have choosen to delete it.
I've been thinking but I can't seem to find the best solution for this. What I need is a solution to only delete the message for the current user.
Should I add some columns in the database that tells which user the private message should be shown for? And when a user deletes the message from the app it only stops showing on that users phone. Or is there a better solution for this?
I need help with some brainstorming. I hope it is an OK question.
Thanks!
A physical delete should probably be avoided. The first couple of reasons I can think of:
how can you do proper testing/audit if the information you're looking for is gone?
legal issues: do you need some levels of data retention?
You can implement some form of logical delete, for example with an extra relation such as UserMessage( UserID, MessageID, MessageStatus ), where MessageStatus could be "unread", "read", "deleted", "important", "spam", etc. (you can map the status to an arbitrary integer if you prefer). When a user deletes a message, you simply change its status in the UserMessage relation, and from the UI side you hide messages which are marked as "deleted".

Resources