poshbotio / PoshBot

Powershell-based bot framework
MIT License
536 stars 108 forks source link

Discord - cannot find user by discord handle with or without tag #226

Open mechaming opened 3 years ago

mechaming commented 3 years ago

Maybe i'm doing something wrong but when updating botadmins it cannot find my account unless I use the GUID*? for my discord handle

Expected Behavior

Adding my discord handle to admins .psd1 should allow me to be an admin with the bot

Current Behavior

Adding my discord handle to admins .psd1 with or with # doesn't give me access BUT if I use my GUID that I read in the output it does work

Possible Solution

Mechanism to resolve discord name to GUID?

Steps to Reproduce (for bugs)

Doesn't work:

$pbc.BotAdmins = @('botaccount','mydiscordhandle')

$pbc.BotAdmins = @('botaccount','mydiscordhandle#1234')

Works: GUID is from verbose output

$pbc.BotAdmins = @('botaccount','12213214342342')

WARNING: {"DataTime":"2021-03-09 17:41:26Z","Class":"DiscordBackend","Method":"UsernameToUserId","Severity":"Warning","LogLevel":"Debug","Message":"User [mydiscordhandle'] not found. Refreshing users","Data":null} WARNING: {"DataTime":"2021-03-09 17:41:26Z","Class":"DiscordBackend","Method":"UsernameToUserId","Severity":"Warning","LogLevel":"Debug","Message":"Could not resolve user [mydiscordhandle']","Data":null} WARNING: {"DataTime":"2021-03-09 17:41:26Z","Class":"Bot","Method":"_LoadAdmins","Severity":"Warning","LogLevel":"Info","Message":"Unable to resolve ID for admin [mydiscordhandle']","Data":null}

Context

Trying to test out bot but can't do anything as I can't run any commands

Your Environment

Windows 10 Pro Powershell Version : 7.1.2

mechaming commented 3 years ago

Okay so I did a little more testing yesterday. I added my discord account to the admin group by using discord ID to give that account access to run commands. To test the username to userid function I tried adding myself to the group through the channel.

!add-groupuser -group admin -name (here I would do the @ and then pull the account I want to have access). This resulted in user not found error from the bot.

I double checked the permissions for the bot in the channel and it has administrator privileges.

@devblackops Would you have any time to assist with me with this?

AndrewJNet commented 3 years ago

Seeing the same issue with a new PoshBot/Discord integration.

@mechaming could you tell me how you made the user an admin by using the ID directly?

AndrewJNet commented 3 years ago

image

@mechaming you may want to try toggling this option, it worked for me. If you want to verify this works for you we can update the documentation to indicate this needs to be toggled on.

eyeiodine commented 2 years ago

image

@mechaming you may want to try toggling this option, it worked for me. If you want to verify this works for you we can update the documentation to indicate this needs to be toggled on.

I can confirm, I had this problem, and this was the fix for me as well.