package main import "github.com/bwmarrin/discordgo" const guildID = "626424729234046987" const memberRoleID = "626434632614805526" func enforceDM(s *discordgo.Session, m *discordgo.MessageCreate) bool { if m.GuildID != "" { //This command can only be used in DM to protect the invite creator. s.ChannelMessageDelete(m.ChannelID, m.ID) s.ChannelMessageSend( m.ChannelID, m.Author.Mention()+",这个指令只能在私信中使用。\n"+m.Author.Mention()+", this command can only be used in DM.", ) return false } return true } func membersOnly(s *discordgo.Session, m *discordgo.MessageCreate) bool { member, err := s.GuildMember(guildID, m.Author.ID) if err != nil { s.ChannelMessageSend( m.ChannelID, m.Author.Mention()+",请在成为会员后才使用这个指令。\n"+m.Author.Mention()+", please use this command after you become a member.", ) return false } for _, v := range member.Roles { if v == memberRoleID { return true } } s.ChannelMessageSend( m.ChannelID, m.Author.Mention()+",请在成为会员后才使用这个指令。\n"+m.Author.Mention()+", please use this command after you become a member.", ) return false }