Add Discord sync to register

Signed-off-by: Etzelia <etzelia@hotmail.com>
discord-sync
Etzelia 2021-07-20 18:54:08 -05:00
parent ac862d8d18
commit ef95635639
No known key found for this signature in database
GPG Key ID: 708511AE7ABC5314
3 changed files with 16 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import (
"git.canopymc.net/Etzelia/canopeas/config" "git.canopymc.net/Etzelia/canopeas/config"
"git.canopymc.net/Etzelia/go-mcm" "git.canopymc.net/Etzelia/go-mcm"
"git.canopymc.net/Etzelia/go-mcm/model"
"git.canopymc.net/Etzelia/go-mcm/model/django" "git.canopymc.net/Etzelia/go-mcm/model/django"
) )
@ -45,8 +46,9 @@ func init() {
} }
var nickname string var nickname string
var player *model.Player
if len(players) > 0 { if len(players) > 0 {
player := players[0] player = players[0]
// Check for a ban // Check for a ban
ban, err := findBan(cmd.config, player.UUID) ban, err := findBan(cmd.config, player.UUID)
@ -103,6 +105,16 @@ func init() {
if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil { if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil {
return "", err return "", err
} }
if player != nil {
player.DiscordID = cmd.message.Author.ID
if status, err := player.Save(); err != nil {
var msg string
if status != nil {
msg = status.Message
}
return msg, err
}
}
// Don't return feedback because this goes in a different channel // Don't return feedback because this goes in a different channel
sendMessage(cmd.session, cmd.config.Register.WelcomeChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false) sendMessage(cmd.session, cmd.config.Register.WelcomeChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false)

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.16
require ( require (
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0 git.canopymc.net/Etzelia/go-mcm v0.0.0-20210720234332-05b38710c5fc
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304
git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f
gitea.com/jolheiser/gojang v0.0.7 gitea.com/jolheiser/gojang v0.0.7

4
go.sum
View File

@ -1,7 +1,7 @@
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 h1:EbxWDS7sOyxv8einE7ps8WsywvlFqyKp3vdvk4PYVw4= git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 h1:EbxWDS7sOyxv8einE7ps8WsywvlFqyKp3vdvk4PYVw4=
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451/go.mod h1:bgGHtcoYFmNIFgcU4P2LwqANZsJxoygnLI0C6OWE/U4= git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451/go.mod h1:bgGHtcoYFmNIFgcU4P2LwqANZsJxoygnLI0C6OWE/U4=
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0 h1:UrwR0Ap4sjoRDfbi/ow76OeBAR9pI+BFKMYU6Jj9EtU= git.canopymc.net/Etzelia/go-mcm v0.0.0-20210720234332-05b38710c5fc h1:OQh94kGqMOE6WFbAyhCRshoQfR/TO/+UkxR1KCIUvaI=
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0/go.mod h1:M9yjY5mBSK5vGVPru7RG6K5bUfoRH7dTtyQ+MCuJ33g= git.canopymc.net/Etzelia/go-mcm v0.0.0-20210720234332-05b38710c5fc/go.mod h1:M9yjY5mBSK5vGVPru7RG6K5bUfoRH7dTtyQ+MCuJ33g=
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 h1:gBzoEToJCO1nKbfhfzhGMgSWY6szwDbA8doVmPr3SIY= git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 h1:gBzoEToJCO1nKbfhfzhGMgSWY6szwDbA8doVmPr3SIY=
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304/go.mod h1:U0H8WgtAzR+L+65odnpUH1lT6z7ylcG6R9keOOTG+fk= git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304/go.mod h1:U0H8WgtAzR+L+65odnpUH1lT6z7ylcG6R9keOOTG+fk=
git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f h1:CupD+6/4Vrx0fGDIFf+cu8ponr19or3bCzkPPQXmRJk= git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f h1:CupD+6/4Vrx0fGDIFf+cu8ponr19or3bCzkPPQXmRJk=