Discord.NET only admins can run this command - discord

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.

Related

How do I check if a user has administrator permission with discord-oauth2-api?

I am making a web panel for my discord bot with a module called discord-oauth2-api and I can get my perms in the servers as permission code like this: 453223243328 but I don't know what does change if a user has administrator in this code so I can't check if a user has administrator.
For what i found the code: 2147483647 under the voice of "permissions" means that the user in the server has "Administrator" permission (the code can even mean the user is the owner of the server).
You can even find if the user is admin with the voice: "permissions_new" which is: 4398046511103.
Thats what i've found, if you what to know more theres a guide from discord for all the values https://discord.com/developers/docs/topics/permissions

Assign role to user in Scratch Org through sfdx command and send email notification to reset the password

I have to create users in scratch org through sfdx cli command and assign profile, role to the user.
The command used is
sfdx force:user:create -u <targetusername> -v <targetdevhubusername> Username=testuser1#my.org LastName=testuser1 Email=me#my.org profileName='System Administrator' generatepassword=true
But I want to assign role as well to the user.
Tried few ways like
Adding parameter to the user create command
UserRole='System Admin'
But its not working.
Can anybody please help me in assigning role to user through sfdx cli.
And once the user is created through Salesforce UI, we have button to Reset Password or checkbox to Generate new password and notify user immediately.
I want to do the same with sfdx cli.
Can anybody help me here. I am stuck since long time.
Thanks in Advance!

Discord.js integration role to bot

Hi everyone i am trying to code my own bot but i don't know to set these auto intergrated roles like this one,can someone explain me how they did this.enter image description here
Bots automatically create their own role with customised permissions(in the invite), the role cannot be added to other users.
When I add a bot to my server, a role is automatically created that is named like the bot.
I don't know if the message in the screenshot is exactly from this, but I can't add members to this bot role or edit it, only the bot has it and can have it.

How can I make my bot read custom status?

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

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