@@ -143,28 +143,26 @@ func runBot(token string) error {
143
143
return err
144
144
}
145
145
146
- filter , err := std .NewMsgFilter (bot )
147
- if err != nil {
148
- return err
149
- }
150
- bot .On (event .MessageCreate , filter .HasBotMentionPrefix , onMessageCreate )
146
+ bot .AddPermission (disgord .PermissionManageChannels )
147
+
151
148
bot .On (event .Ready , onReady )
152
149
153
- bot .AddPermission (disgord .PermissionManageChannels )
154
- url , err := bot .CreateBotURL ()
150
+ filter , err := std .NewMsgFilter (bot )
155
151
if err != nil {
156
152
return err
157
153
}
154
+ bot .On (event .MessageCreate , filter .HasBotMentionPrefix , onMessageCreate )
158
155
159
- logr .Info ("Starting bot connection " )
156
+ logr .Info ("Connecting " )
160
157
start := time .Now ()
161
158
if err = bot .Connect (); err != nil {
162
159
return err
163
160
}
164
161
logr .Info ("Connection took " , time .Since (start ))
165
- logr .Infof ("Link to add the bot to your server:\n %s" , url )
166
162
163
+ logr .Info ("Press Ctrl+C to exit" )
167
164
bot .DisconnectOnInterrupt ()
165
+
168
166
return nil
169
167
}
170
168
@@ -174,13 +172,21 @@ func onReady(session disgord.Session, evt *disgord.Ready) {
174
172
})
175
173
if err != nil {
176
174
logr .Error (err )
177
- return
175
+ } else {
176
+ guildString := "Connected guilds:\n "
177
+ for i , guild := range guilds {
178
+ guildString += fmt .Sprintf ("%d: %s (%s)\n " , i + 1 , guild .Name , guild .ID )
179
+ }
180
+ logr .Info (guildString )
178
181
}
179
- guildString := "Connected guilds:\n "
180
- for i , guild := range guilds {
181
- guildString += fmt .Sprintf ("%d: %s (%s)\n " , i + 1 , guild .Name , guild .ID )
182
+
183
+ user , err := session .GetCurrentUser ()
184
+ if err != nil {
185
+ logr .Error (err )
186
+ } else {
187
+ url := fmt .Sprintf ("https://discordapp.com/oauth2/authorize?scope=bot&client_id=%s&permissions=%d" , user .ID , session .GetPermissions ())
188
+ logr .Infof ("Link to add bot to your guild:\n %s" , url )
182
189
}
183
- logr .Info (guildString )
184
190
}
185
191
186
192
func onMessageCreate (session disgord.Session , evt * disgord.MessageCreate ) {
0 commit comments