Results 1 to 6 of 6

Thread: [RESOLVED] Discord Bot message.Author

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2022
    Posts
    62

    Resolved [RESOLVED] Discord Bot message.Author

    Hello,
    how can I check if the user is admin or a RoleID inside?

    Have already tried many things but unfortunately no further ;/

    Check for user name I do so, but that's too stupid for me :/

    Code:
    Private Async Function Onmsg(message As SocketMessage) As Task
     If message.Author.Username = "TestUser" Then
                MsgBox("is Admin")
            End If
    End Function
    Code:
    If userMessage.?????
    Last edited by StikxX; Jul 18th, 2022 at 06:19 PM.

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2022
    Posts
    62

    Re: Discord Bot message.Author

    No one has an idea? :/

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,803

    Re: Discord Bot message.Author

    Quote Originally Posted by StikxX View Post
    No one has an idea? :/
    Someone might have an idea but we have no idea what you're talking about here.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2022
    Posts
    62

    Re: Discord Bot message.Author

    Sorry, I expressed myself badly.

    I have built a Discord bot.
    When a user sends a message to the bot, it should check if the user is in a certain group (RoleID).
    If yes then... if no then....

  5. #5
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,140

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2022
    Posts
    62

    Re: Discord Bot message.Author

    Done:
    Code:
    If userMessage.Contains("!say ") And DirectCast(message.Author, SocketGuildUser).Roles.ToList.Contains(DirectCast(message.Channel, IGuildChannel).Guild.GetRole("roleid")) Then

    i use the Discord Nuget

    Code:
    Imports Discord
    Imports Discord.WebSocket
    
    Public Class Form1
    
    Dim DiscordSocketClient As DiscordSocketClient
    
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            DiscordSocketClient = New DiscordSocketClient(New DiscordSocketConfig With {
                                                           .LogLevel = LogSeverity.Verbose
                                                          })
            AddHandler DiscordSocketClient.MessageReceived, AddressOf Onmsg
     RunBot().GetAwaiter()
        End Sub
    
        Async Function RunBot() As Task
            Await DiscordSocketClient.LoginAsync(TokenType.Bot, "***************")
            Await DiscordSocketClient.StartAsync()
            Await DiscordSocketClient.SetGameAsync("~help | Test")
            Await Task.Delay(-1)
        End Function
    
        Private Async Function Onmsg(message As SocketMessage) As Task
            Dim userMessage As String = message.Content.ToString()
            If userMessage.StartsWith("!") Then 'If it's an command
                If userMessage.Contains("stop") Then
                    Await message.Channel.SendMessageAsync("", False, embed.Build())
                    MsgBox("stop")
                End If
                If userMessage.Contains("start") Then
                    MsgBox("start")
                End If
            End If
    End Function
    Last edited by StikxX; Jul 18th, 2022 at 11:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width