some cleanup
This commit is contained in:
parent
16ee889aae
commit
1a8de9b9fd
3 changed files with 23 additions and 16 deletions
|
@ -22,17 +22,18 @@ var (
|
|||
|
||||
func main() {
|
||||
log.SetLevel(log.LevelInfo)
|
||||
log.Info("starting joinbot...")
|
||||
log.Info("starting tempbot...")
|
||||
log.Info("disgo version: ", disgo.Version)
|
||||
|
||||
// intents needed GUILD_MESSAGES
|
||||
// permissions: Manage Messages
|
||||
// intent:
|
||||
client, err := disgo.New(token,
|
||||
bot.WithGatewayConfigOpts(
|
||||
gateway.WithIntents(gateway.IntentsAll),
|
||||
gateway.WithIntents(gateway.IntentsNone),
|
||||
),
|
||||
bot.WithCacheConfigOpts(
|
||||
cache.WithCacheFlags(
|
||||
cache.FlagsAll,
|
||||
cache.WithCaches(
|
||||
cache.FlagsNone,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -43,6 +44,10 @@ func main() {
|
|||
|
||||
defer client.Close(context.TODO())
|
||||
|
||||
if err = client.OpenGateway(context.TODO()); err != nil {
|
||||
log.Fatal("error while connecting to gateway: ", err)
|
||||
}
|
||||
|
||||
channels, err := client.Rest().GetGuildChannels(registerGuildID)
|
||||
for _, channel := range channels {
|
||||
switch channel.Name() {
|
||||
|
|
|
@ -40,7 +40,7 @@ type appleApiBody struct {
|
|||
|
||||
func main() {
|
||||
log.SetLevel(log.LevelInfo)
|
||||
log.Info("starting voicechannelbot...")
|
||||
log.Info("starting vcbot...")
|
||||
log.Info("disgo version: ", disgo.Version)
|
||||
|
||||
err := loadAppleList()
|
||||
|
@ -49,7 +49,8 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
// intents needed
|
||||
// permissions: Manage Channels
|
||||
// intents:
|
||||
client, err := disgo.New(token,
|
||||
bot.WithGatewayConfigOpts(
|
||||
gateway.WithIntents(gateway.IntentGuildVoiceStates),
|
||||
|
@ -89,7 +90,7 @@ func main() {
|
|||
log.Fatal("couldn't find needed channel")
|
||||
}
|
||||
|
||||
log.Infof("voicechannelbot is now running. Press CTRL-C to exit.")
|
||||
log.Infof("vcbot is now running. Press CTRL-C to exit.")
|
||||
s := make(chan os.Signal, 1)
|
||||
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||
<-s
|
|
@ -33,17 +33,18 @@ var (
|
|||
|
||||
func main() {
|
||||
log.SetLevel(log.LevelInfo)
|
||||
log.Info("starting example...")
|
||||
log.Info("starting welcomebot...")
|
||||
log.Info("disgo version: ", disgo.Version)
|
||||
|
||||
// intents needed GUILD_MEMBER_ADD (from GUILD_MEMBERS)
|
||||
// permissions: Manage Roles
|
||||
// intent: Server Members Intent
|
||||
client, err := disgo.New(token,
|
||||
bot.WithGatewayConfigOpts(
|
||||
gateway.WithIntents(gateway.IntentGuildMembers),
|
||||
),
|
||||
bot.WithCacheConfigOpts(
|
||||
cache.WithCacheFlags(
|
||||
cache.FlagsAll,
|
||||
cache.WithCaches(
|
||||
cache.FlagsNone,
|
||||
),
|
||||
),
|
||||
bot.WithEventListenerFunc(joinListener),
|
||||
|
@ -88,7 +89,7 @@ func main() {
|
|||
log.Fatal("couldn't find needed role")
|
||||
}
|
||||
|
||||
log.Infof("joinbot is now running. Press CTRL-C to exit.")
|
||||
log.Infof("welcomebot is now running. Press CTRL-C to exit.")
|
||||
s := make(chan os.Signal, 1)
|
||||
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||
<-s
|
||||
|
@ -97,7 +98,7 @@ func main() {
|
|||
func joinListener(event *events.GuildMemberJoin) {
|
||||
// on join send message in welcome
|
||||
user := event.Member.User
|
||||
if event.GuildID != registerGuildID {
|
||||
if event.GuildID.String() != registerGuildID.String() {
|
||||
event.Client().Logger().Error("join from an other guild")
|
||||
return
|
||||
}
|
||||
|
@ -137,7 +138,7 @@ func reactionListener(event *events.ComponentInteractionCreate) {
|
|||
}
|
||||
|
||||
approverID := event.User().ID
|
||||
if approverID == event.Client().ID() {
|
||||
if approverID.String() == event.Client().ID().String() {
|
||||
// reaction user is bot itself
|
||||
return
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ func reactionListener(event *events.ComponentInteractionCreate) {
|
|||
}
|
||||
hasPermission := func() bool {
|
||||
for _, roleID := range approver.RoleIDs {
|
||||
if roleID == roleAppleCoreID {
|
||||
if roleID.String() == roleAppleCoreID.String() {
|
||||
return true
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue