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

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

Related

Cannot find discord bot after successfully authorizing

I am new to creating a discord bot. I hope you can all give me a good solution to my problem.
I tried to create a bot for a company's server and followed a free guide. I had one problem when adding the bot to the server.
I got a message that the authorization succeeded but I cannot find the bot on the server. The guide clearly mentioned that I can find an offline bot. So I created my own discord server and tried again. OMG, it went well.
What's the problem?
Should I change the discord server setting? If yes, which option?
I think that the server settings are done in the way that the bot does not have a permissions to be in the channel you are trying to find it in. If you have admin permissions take a look into User management in server settings if the bot did or did not join and if it did, give it some permissions so that it has an access to the channel you want to see it in.
(On the right panel you see member of the channel you are currently clicked onto not the entire server.)

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.

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.

Salesforce Author Apex option not available under Administrative Permissions section

I have created a new account in Sales force and trying to run the default API's from Developer Console.My account has System Administrator Role.
But, Open Execute Anonymous Window is disabled for me and am not able to run any API,getting error 'You don't have the permission to execute Apex'.
So i tried to Enable Author Apex in SetUp,but i am not able to see that option under Administrative Permissions section
How to enable Author Apex? ,so that i can use the developer console.
You should check user license assigned to your user. I think user license assigned to your user don't have author apex permission.

Login and Logout AD with C#

How can i login without logout from current user to another Active Directory user with C#. ;
1-Getting new user's access
2- doing my work and than logout with c# same way.
For example i am a user at blabla.com domain.I have logged in a Power User.But i need Admin Rights for something so i need to logout and change user to Administrator do my job and relogin with Power User again.I wanna do it with C#.
I heard something like that Impersonate User but i think this is not what i want.
Edited : I want login with another user and get this user's permissions without logout from my current user in c#.
Your question is not very clear. If what you want to be doing is querying/modifying AD, then t4zsan's answer is correct.
If you just need the other user's groups/security permissions, then Impersonation is the way to go. This article will give you a good foundation on it.
Caveats: The user you wish to impersonate must be able to logon to the machine you are running the code on. You can't impersonate a user in another domain if that domain is not trusted. Nor can you impersonate a local user on another machine, obviously.
When using the classes in System.DirectoryServices to connect to AD you have the option of specifying user credentials. For example when using DirectoryEntry there is a constructor overload taking username and password that lets you connect as a different user.

Resources