I code a discord bot in discord.js and I have an economy with hunger and fun as a variable. I want those variables to decrease over time, and I would need a for loop to do this, but I don't know how I would access every single account hunger variable. Normally what I would do to change something is have the user be the message author id but since it happens at all times i cant connect it to a authors message.
Related
So I have added member count to the bot but I discovered something a bit strange.
If I use guild.memberCount I get the same result as the counter on the server settings page.
But if I use guild.members.cache.size I get a different result number.
Example
guild.memberCount says 1335 (Same as Server Settings Page)
guild.members.cache.size says 1332
Is there a reason why it keeps removing 3?
W do not use bot user filters. Just a total count.
Not all members will be in the cache. Generally, they only become cached once they send a message, at which point they're stored temporarily in memory.
guild.memberCount, on the other hand, is the member count directly received from Discord's API.
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.
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"))
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.
SITUATION :
I have an application where i have to issue a gift cupon kind of a thing when the user reaches a certain score say 'x'.
I want to create a coupon with a unique QRcode, at the time the user reaches the score 'x' so that he can download it on his iphone and use it. Once it is used , the cupon should be invalidated. this applies to any user using the application. Meaning a coupon is created once the score is reached and deleted or invalidated once it is used.
ISSUE :
I'm not able to figure out how to create a cupon everytime any user reaches the score. Ofcourse, i did go through a lot of documentations and links like http://www.raywenderlich.com/20734/beginning-passbook-part-1. I also tried using pass-source but the valid account requires you to pay minimum about 8$.
As suggested in raywenderlich tutorials, i can create passes but thats not created through the application.
Also i didn't see any method where we can be notified when a user uses his issued coupon so that we can invalidate it.
Am i missing something here?
"Using" a QR code on a coupon means it is scanned by something else. That something else has to take responsibility to report the activity back to you, so you could then update the pass with an "Expired" flag in your database, re-sign and rebuild the pass, issue the push notification so that it would eventually update on the device. You'd also probably want that scanner-thingie to check with you to see that the code is valid before accepting it. So, yeah, not Apple's problem.