Prepare for open source: Apache-2.0 license, contributing guide, self-hosting guide, fix Close()
- LICENSE (Apache-2.0), NOTICE, CONTRIBUTING.md - docs/self-hosting.md and README sections for hosting and contributing - Close() no longer crashes: it only disconnects and leaves the slash commands registered, so they keep their IDs across restarts - Tests use a neutral server ID Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
279607183a
commit
1fbc38ca56
10 files changed
+503
-30
No files matched your search
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
const (
|
||||
appID = "100"
|
||||
betaServer = "1170934850157547600"
|
||||
betaServer = "700000000000000001"
|
||||
optedIn = "222"
|
||||
leftServer = "333"
|
||||
)
|
||||
@@ -219,3 +219,22 @@ func TestBetaCleanupIsRetriedAndGivesUpWhenTheBotIsGone(t *testing.T) {
|
||||
t.Error("a server the bot can't reach any more is forgotten")
|
||||
}
|
||||
}
|
||||
|
||||
// Close used to loop over a list that started with empty entries and read
|
||||
// their IDs, so shutting down crashed. It must just disconnect, and must not
|
||||
// touch the registered commands.
|
||||
func TestCloseDoesNotTouchCommands(t *testing.T) {
|
||||
d := &fakeDiscord{cmds: map[string][]*discordgo.ApplicationCommand{
|
||||
"1": {{ID: "7", Name: "ping"}},
|
||||
}, failures: map[string]int{}}
|
||||
b := newTestBot(t, d)
|
||||
b.GuildID = "1"
|
||||
b.Commands = []*discordgo.ApplicationCommand{{Name: "ping"}}
|
||||
|
||||
if err := b.Close(); err != nil {
|
||||
t.Fatalf("Close on a bot that never connected: %v", err)
|
||||
}
|
||||
if len(d.deleted) != 0 {
|
||||
t.Errorf("Close must not delete commands: %v", d.deleted)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user