How can I make my bot read custom status? - discord

Hey I was just wondering if its possible to make my bot read users custom status so if it matches it gives the a role, By this I mean If they have my discord server invite link they recieve the supporter role is that possible?

Check the User#Presence part.
Then you can get their status and even their activity message.
To add a role to a member, make sure to check GuildMemberRoleManager#add.

Yes, that is possible.
It's included in the activities:
message.member.guild.presences.cache
This will return all the activities from all members in a guild.
Discord.js: https://discord.js.org/#/docs/main/stable/class/Presence?scrollTo=activities

Related

Discord.NET only admins can run this command

i want to make a command in Discord.NET that only can be ran by admins.
It would be great if anyone could give me an example thank you!
A command is basically a message that gets sent to the bot. You simply check if the message sender has a specific role ID. An admin role also has a role ID, if the role ID's match, you continue with the command.

Discord bot get user id by only name

So I'm currently making a bot that should dm users who entered their discord name(example#0000) outside of discord, I now need the bot to convert their names into their Id's, in order to dm them.
Is that even possible?
For clarification, the bot is not on the same server as the users and has never interacted with them.
No, it’s not possible to get a User/Member instance by name if you don’t share a guild, the only possible way would be to fetch it from the API using an ID
user = await bot.fetch_user(123345567901)

Make it so that a someone cannot react to a discord message until a channel has been deleted

So basically I have a support bot that creates a channel when someone reacts that only staff have access to. In order to prevent abuse I want to make it so that a new channel channel cannot be created by the same person unless the a previously open channel is deleted.
Give your bot access to the AuditLogs will allow you to see who is creating the channels but I suspect that's not gonna help because the bot will be the one creating and deleting the channels, for the discord server he is the owner of the action.
Maybe the only way is to store in the bot code a map of the channel id and his owner (user that typed the command). With this every time a user try to create a new channel you can check on your map if there is any channel active for that user and if there is show some kind of error message.

How to transfer a discord server ownership with a bot

There is any way of transfering a discord server ownership with a bot?
I have beed told that there is a way to do this with a python bot but I didn't figure out how.
It seems that a method exists on the discord.js wrapper. .setOwner()
I couldn't find a way to see if it really works. ^^
// Edit the guild owner
guild.setOwner(guild.members.cache.first())
.then(updated => console.log(`Updated the guild owner to ${updated.owner.displayName}`))
.catch(console.error);
you can actually change server ownership with a bot. but the bot must be the owner of the server before hand.
for a bot to create a guild it must use POST /guilds
to change owners you must use PATCH /guilds/{guild.id} and send over the json parameter owner_id with the id you want to transfer ownership too.
Offical Discord Documentation Links:
https://discordapp.com/developers/docs/resources/guild#create-guild
https://discordapp.com/developers/docs/resources/guild#modify-guild

This error "DiscordAPIError: Missing Permissions" does not stop

I have a problem, and that is that every moment I get this error: DiscordAPIError: Missing Permissions and I don't know where it comes from or why
I'm not sure if anyone will still run into this issue but if you do. It could be a problem with your BOT being a lower level than the user or whatever your trying to do. For example most people have the Owner role on the top right? right. Well if you're trying to do something to a user above your bot like if the role BOT is under MEMBER and you try Banning MEMBER with BOT it won't work. Hope this helps
In 2021 this error can be fixed, if you are trying to let's say for example to create a ban all command for your discord bot, YOU HAVE TO DO THIS BEFORE GIVING UP ON IT. First go to https://discord.com/developers/applications and click on your bot's account then go to the option bot(the location were you get the bot token) then turn on those options:
EASY DIRECTIONS: Discord Developer Portal>(Click on your bot's account)>Bot(the place were you are getting the token from)>Privileged Gateway Intents>PRESENCE INTENT(TURN IT ON IF IT'S OFF)>SERVER MEMBERS INTENT(IT'S LOCATED IN THE SAME PAGE, TURN IT ON IF IT'S OFF) Those are the main thing that you have to do and then you can start to make your command!
In addition to the other answers given, I also needed to go to Server Settings > Roles. There you have a draggable list of roles available on your server. Drag your bots auto-assigned role (the bots name) to the top of the list. This will give it permission to assign subordinate roles.
I ran into this problem and it was because that I didn't give my bot the role to write in the channel. So make sure that your bot has the persmission to your channel.

Resources