Discord.js event random avatar - discord.js

i'm trying to make a system. I want the members on the server to randomly select and send every minutes the "jpeg/png" photos in their profile to the specified channel. something like a "png-archive". I do not know how to do it.can u help ?

You can run this inside of an infinite loop (search on internet how to setup it) :
let avatarEmbed = new Discord.MessageEmbed()
.setColor(colorcode)
.setAuthor(member.username)
.setImage(member.displayAvatarURL());
channel.send(avatarEmbed);
Replace colorcode by a color of your choice, member by the member you want the bot to display the profile picture (if you want all the members to be selected you can get the Collection of all members then run this inside of a foreach loop) and channel by the channel object.

Related

Automatic Role-Messages (Discord)

I don't know if it's possible but I need help!
So, each member has picked a role with the Carlbot:s reaction-role...
**I want to make a button in a channel that sends a message to other members with the SAME ROLE as the person who pressed it. **
(it would be absolutely fantastico if they couldn't write in the chat/channel. The only way they can interact is via the button.)*
Thanks in advance!
//Grenmyr
I've tried to create a webhook linked with zapier. But it can't read the pressers role(roles).

Store data in discord message for button component

I want to make a simple bot that does some things when someone clicks a list item.
To make this possible I need to store the list item's id in the message. I didn't see any ways to store data in a message without showing it, so I added it to the footer and when the button triggers it gets the first embed's footer in the interaction's message.
My problem with this solution is that it looks bad.
Collectors are not an option because these list items are sent to a channel once when the channel is created, and if the bot restarts the collectors won't trigger.
How would you guys solve this?
Thanks!
Okay I solved this. I don't know how I've never thought of this before.
Basically I created a table in my database that has 2 columns:
discord message id
data
When I send the message to the channel I just store the data with the message's id. When the user clicks the button I just retrieve the data by the message id.

Discord.js How to list the display names of all members with a specific role

I have a command that currently gives a count of how many people have a specific role. That functions properly. I am attempting to make a subcommand of that command that will list the members who have that role and I can get it to list their names as usernames, but I'm looking for it to list it as a display name instead.
This is the code that currently works
let nameList= message.guild.roles.resolve('Role-ID').members.map(m=>m.user.username).join('\n');
The "Role-ID is the actual ID in my code. I know that the displayName is a property of the GuildMember but I don't know how to integrate it here. Thoughts?
I figured it out, but instead of deleting my post I figured I would post the solution.
All I needed to do was change .user.username to .displayName
let nameList= message.guild.roles.resolve('Role-ID').members.map(m=>m.user.username).join('\n');

How can I count the number of reactions in discord.js?

I have a vote pool with 2 reactions :thumbs_up: :thumbs_down: in my bot but I'm not able to count the number of people who thumbs_up and thumbs_down and I'm not able to return the value back to the program.
It is showing ReferenceError : reaction not defined, how to define reaction?
To get a count of existing reactions, you first need a valid Message object. If you're using a poll command or something of the sort, you'll want to store the initial message you send for access later.
// make sure your function is async
const msg = await message.channel.send('This is a poll or something');
You can then use the reactions property to get a collection of MessageReactions. The collection is mapped by the emoji ID if it is custom, and the emoji itself if it is Unicode (such as πŸ‘and πŸ‘Ž). Each MessageReaction has a count property, so you can see who reacted to both.
const reactions = msg.reactions.cache;
reactions.get('πŸ‘'); // number of people who react thumbs-up
reactions.get('πŸ‘Ž'); // number of people who react thumbs-down
What you're looking for is called a reaction collector. To be able to use reaction, you must use it inside any of collector's events. You can view every event here.

Deleting every channel in a specified category in discord.py

I am trying to delete every channel in a specified category in discord.py.
My code so far:
category = client.get_channel(my_id_here)
I was thinking of iterating through each of the channels in that category however I'm not sure how to go about doing so.
I saw a similar post on this however that's in discord.js so I would need the discord.py equivalent.
Figured out the solution, hope it helps someone:
category = client.get_channel(id_here)
for channel in category.voice_channels:
await channel.delete()
If you want to remove text channels, replace voice_channels with text_channels

Resources