feat: bot status (#30)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #30
This commit is contained in:
parent
a1bf5f94fa
commit
3fcf38f5c7
|
@ -43,6 +43,8 @@ func NewBot(token string, groupSvc GroupService, monitorSvc MonitorService, clie
|
||||||
return nil, fmt.Errorf("discordgo.New: %w", err)
|
return nil, fmt.Errorf("discordgo.New: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.Identify.Intents = discordgo.IntentsNone
|
||||||
|
|
||||||
b := &Bot{
|
b := &Bot{
|
||||||
s: s,
|
s: s,
|
||||||
c: cron.New(
|
c: cron.New(
|
||||||
|
@ -56,6 +58,8 @@ func NewBot(token string, groupSvc GroupService, monitorSvc MonitorService, clie
|
||||||
choiceSvc: client,
|
choiceSvc: client,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.s.AddHandler(b.handleSessionReady)
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +117,10 @@ func (b *Bot) initCron() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bot) handleSessionReady(s *discordgo.Session, _ *discordgo.Ready) {
|
||||||
|
_ = s.UpdateGameStatus(0, "Tribal Wars")
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bot) Close() error {
|
func (b *Bot) Close() error {
|
||||||
<-b.c.Stop().Done()
|
<-b.c.Stop().Done()
|
||||||
return b.s.Close()
|
return b.s.Close()
|
||||||
|
|
|
@ -35,11 +35,13 @@ func (c *groupCommand) create(s *discordgo.Session) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var perm int64 = discordgo.PermissionAdministrator
|
var perm int64 = discordgo.PermissionAdministrator
|
||||||
|
dm := false
|
||||||
|
|
||||||
_, err = s.ApplicationCommandCreate(s.State.User.ID, "", &discordgo.ApplicationCommand{
|
_, err = s.ApplicationCommandCreate(s.State.User.ID, "", &discordgo.ApplicationCommand{
|
||||||
Name: c.name(),
|
Name: c.name(),
|
||||||
Description: "Manages groups on this server",
|
Description: "Manages groups on this server",
|
||||||
DefaultMemberPermissions: &perm,
|
DefaultMemberPermissions: &perm,
|
||||||
|
DMPermission: &dm,
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
{
|
{
|
||||||
Name: "create",
|
Name: "create",
|
||||||
|
|
|
@ -33,11 +33,13 @@ func (c *monitorCommand) register(s *discordgo.Session) error {
|
||||||
|
|
||||||
func (c *monitorCommand) create(s *discordgo.Session) error {
|
func (c *monitorCommand) create(s *discordgo.Session) error {
|
||||||
var perm int64 = discordgo.PermissionAdministrator
|
var perm int64 = discordgo.PermissionAdministrator
|
||||||
|
dm := false
|
||||||
|
|
||||||
_, err := s.ApplicationCommandCreate(s.State.User.ID, "", &discordgo.ApplicationCommand{
|
_, err := s.ApplicationCommandCreate(s.State.User.ID, "", &discordgo.ApplicationCommand{
|
||||||
Name: c.name(),
|
Name: c.name(),
|
||||||
Description: "Manages monitors",
|
Description: "Manages monitors",
|
||||||
DefaultMemberPermissions: &perm,
|
DefaultMemberPermissions: &perm,
|
||||||
|
DMPermission: &dm,
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
{
|
{
|
||||||
Name: "create",
|
Name: "create",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user