Keep track of guild states.

We don't currently bridge anything, but this just keeps everything in sync
with the discord server.
This commit is contained in:
Gary Kramlich
2022-03-29 07:10:16 -05:00
parent d4355779a6
commit 928a49b42d
7 changed files with 295 additions and 8 deletions

View File

@@ -53,6 +53,8 @@ type commands struct {
Reconnect reconnectCmd `kong:"cmd,help='Reconnect to Discord'"`
Version versionCmd `kong:"cmd,help='Displays the version of the bridge.'"`
Guilds guildsCmd `kong:"cmd,help='Guild bridging management.'"`
LoginMatrix loginMatrixCmd `kong:"cmd,help='Replace the puppet for your Discord account with your real Matrix account.'"`
LogoutMatrix logoutMatrixCmd `kong:"cmd,help='Switch the puppet for your Discord account back to the default one.'"`
PingMatrix pingMatrixCmd `kong:"cmd,help='check if your double puppet is working properly'"`
@@ -286,3 +288,23 @@ func (m *pingMatrixCmd) Run(g *globals) error {
return nil
}
///////////////////////////////////////////////////////////////////////////////
// Guilds Commands
///////////////////////////////////////////////////////////////////////////////
type guildsCmd struct {
Status guildStatusCmd `kong:"cmd,help='Show the bridge status for the guilds you are in'"`
}
type guildStatusCmd struct{}
func (c *guildStatusCmd) Run(g *globals) error {
g.user.guildsLock.Lock()
defer g.user.guildsLock.Unlock()
for _, guild := range g.user.guilds {
fmt.Fprintf(g.context.Stdout, "%s %s %t\n", guild.GuildName, guild.GuildID, guild.Bridge)
}
return nil
}