So... we see you haven't signed up here on our website.  

Do you really want to sit here and be "Unregistered" all your life?  No, of course you don't!  So, click this here link and you'll take that all important first step into enlightenment! (or something, whatever...)

[DOC] How to Create / Setup a Discord bot with RAT

Discussion in 'General' started by Trekkan, Sep 1, 2017.

  1. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    First, you need to create an application within Discord. You can use an existing app, but it is recommended you create a new app.

    Go here: Discord API Docs for Bots and Developers

    Log in, and click the New app image.

    Type in an App name, it can be anything but it should be unique. This will also be the name that people will see your bot listed as in your server/channels.

    Add anything to the description or app icon you want, DO NOT check add Redirect.

    Copy and paste the clientID somewhere

    Click Create a Bot Username
    Make sure "Public Bot" is unchecked

    Click Save Changes at the bottom of the screen

    Click the "Click to Reveal" link nex to the Token field under "App Bot User", copy and paste this somewhere.

    You've now created your first bot and user. =)

    Now you need to authorize this new bot to join your server.

    Code:
    https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot
    &permissions=0
    Edit the above URL, replacing CLIENT_ID with the client ID you cut/pasted earlier.

    Go there in any browser. You only need to do this once, or if you somehow unauthorize the bot.

    Now, in RAT, click the Discord setup icon on the toolbar (the last icon as of this writing)

    Check the Enable Bot box
    Check the Auto Re/Connect box

    If you want your bot to have a different name than your app, type that into the Bot Name box.
    Paste the token into the Bot Token box
    Click Test Connection

    Assuming everything is ok, you'll get a popup stating so, and now the Bot Channel box will populate with the channels on your server. Select the channel you want your bot to reside in.

    Click Save Setttings
     
    Last edited: Sep 3, 2017
  2. TOP-ic

    TOP-ic New Member

    Points:
    34
    I was able to add the bot only on this link:
    Code:
    https://discordapp.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot&permissions=0
     
  3. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    Interesting, I'll have to look up the permissions argument. Thanks!
     
  4. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    Seems as though someone else needed the permissions argument on there as well. Updated my first post with that info, thanks again!
     
  5. djkrose

    djkrose New Member

    Points:
    34
    I just set it up on my server/channel and it works. Very nice!

    Is it correkt that it is only a one-way link from game to Discord? Or can people from Disord somehow talk back into the game? Maybe even issue commands? If so, how?
     
  6. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    Sure, you can reply, you'll need to add a new event for something like !SAY
    Conditional: STARTSWITH:!say||CHECKDISCORDROLE:>=Discord Admins
    Script: say "[{player_name}]: {0}"

    Change the "Discord Admins" to a roll in Discord that you want to be able to use the chat command. Note that I think there is an issue using the default roles, so make a new one and set it to that. I'll work on that bug later.
     
  7. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    Also, you'd do the same thing for any commands you'd want, just set the access level they need in Discord, and do whatever you want them to do in the script.
     
  8. TOP-ic

    TOP-ic New Member

    Points:
    34
    Good day! I understand that the above asked about feedback discord-->server.
    I have configured the server --> discord and works great. But how to do to be able to write in discorde and displayed on the server, I don't understand. Prompt, please, in more detail. Thank you.
     
  9. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    I'm a bit unclear as you said you have it working from Server -> Discord, but that you want to write in Discord and show it on the server? That appears to be the same thing? The above response to djkrose does exactly that?

    But to try and make that example more clear.

    Create a new event, and set it with these parameters.

    Type: Player Public Chat
    Conditional: STARTSWITH:!say||CHECKDISCORDROLE:>=Discord Admins
    Script: say "[{player_name}]: {0}"

    Then, when you want to say something on the server, from discord, type:!say This is going to appear in the 7D2D game chat.

    If you want your game chat to be displayed in Discord. Then edit the last event for Player Public Chat, it has an order of 9999 on it.

    Add to the Script: .DSAY:<{player_name}> {player_chat}

    That will display any chat the players type in the game, in Discord.

    Those two options will cover both Game Server -> Discord and Discord -> Game Server.
     
    • Like Like x 1
  10. TOP-ic

    TOP-ic New Member

    Points:
    34
    Sorry if not clear . Still the Google translator. )))
    1. Established in the RAT that you wrote.
    1.jpg
    2. Write text in the programm Discord
    2.jpg
    3. The message appears in the tab Discord
    3.jpg
    4. But the chat is empty. (((
    4.jpg

    I missed something?

    And again. I have duplicated messages. )))
    5.jpg
     
    Last edited: Sep 22, 2017
  11. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    In Step 1, you have defined the command that RAT will listen for as !say

    You also need to make sure that you either change the Discord role: Discord Admins, to a role that exists on your Discord server, or create that role and assign it to anyone you want to be able to chat in from Discord, into the 7D2D game.

    So, if you want something in Discord to appear in the game chat, you need to prefix what you say with !say.

    Example:

    !say this is a test
    !say Hello from Discord!
     
    • Like Like x 1
  12. TOP-ic

    TOP-ic New Member

    Points:
    34
    Apparently I am very stupid, something does not work )))) But thanks for the help.
     
  13. TOP-ic

    TOP-ic New Member

    Points:
    34
    Yay! I did. Thank you very much, it's just amazing.
     
    • Like Like x 1
  14. TOP-ic

    TOP-ic New Member

    Points:
    34
    Strange, but the connection is discord -> the server stopped working. In the settings did nothing. Two days worked, then stopped.
     
  15. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    I've had one other report of this, I was told that rebooting was the only thing that allowed the connection to work again. If you can, please try that and let me know. It'll give me more information to work with when troubleshooting the issue.
     
  16. TOP-ic

    TOP-ic New Member

    Points:
    34
    Unfortunately restarting the RAT, server, and discord did not fix the situation. The report does not come with discord to the server.
     
  17. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    I meant reboot the machine that RAT is running on. It shouldn't matter, but I'm told that fixed it for someone. So that's what I'm trying to test sinec I haven't encountered the issue.
     
  18. TOP-ic

    TOP-ic New Member

    Points:
    34
    Restarting the PC on which you installed the RAT did not help to rectify the situation.
     
  19. Trekkan

    Trekkan JFF Administrator Staff Member

    Points:
    943
    I'm able to reproduce many issues with this. It looks like the Discord service upgrade caused some issues with backward compatibility... so I need to dig into this a lot more. Basically, don't bother trying at the moment, its broken. I'll update as soon as I have something new.
     
    • Like Like x 1

Share This Page