mirror of https://github.com/hak5/scuzzy.git
Misc: Remove Member Count, Remove f.Config.Guild
parent
8cc0c09db1
commit
bc1a7952a3
|
@ -65,6 +65,8 @@ func main() {
|
|||
|
||||
// Enable Message Caching (Last 1024 Events)
|
||||
bot.State.MaxMessageCount = 1024
|
||||
bot.State.TrackChannels = true
|
||||
bot.State.TrackMembers = true
|
||||
|
||||
// Open Connection
|
||||
err = bot.Open()
|
||||
|
@ -73,12 +75,14 @@ func main() {
|
|||
}
|
||||
|
||||
// Setup Auth
|
||||
Config.Guild, err = bot.Guild(Config.GuildID)
|
||||
g, err := bot.Guild(Config.GuildID)
|
||||
if err != nil {
|
||||
log.Fatal("[!] Error: " + err.Error())
|
||||
}
|
||||
var p *permissions.Permissions
|
||||
p = permissions.New(&Config, Config.Guild)
|
||||
p = permissions.New(&Config, g)
|
||||
|
||||
Config.GuildName = g.Name
|
||||
|
||||
// Setup Handlers
|
||||
f := features.Features{
|
||||
|
|
|
@ -160,7 +160,7 @@ func (f *Features) ProcessUserJoin(s *discordgo.Session, m *discordgo.GuildMembe
|
|||
}
|
||||
|
||||
for _, roleID := range f.Config.JoinRoleIDs {
|
||||
err = s.GuildMemberRoleAdd(f.Permissions.Guild.ID, m.User.ID, roleID)
|
||||
err = s.GuildMemberRoleAdd(f.Config.GuildID, m.User.ID, roleID)
|
||||
if err != nil {
|
||||
log.Print("[!] Error (User Join)" + err.Error())
|
||||
return err
|
||||
|
|
|
@ -250,7 +250,7 @@ func (f *Features) handleInfo(s *discordgo.Session, m *discordgo.MessageCreate)
|
|||
desc += "**Language**: Go\n"
|
||||
desc += "**Commands**: See `" + f.Config.CommandKey + "help`\n\n\n"
|
||||
|
||||
gm, err := s.GuildMember(f.Config.Guild.ID, s.State.User.ID)
|
||||
gm, err := s.GuildMember(f.Config.GuildID, s.State.User.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ func (f *Features) handleRules(s *discordgo.Session, m *discordgo.MessageCreate)
|
|||
}
|
||||
|
||||
msg := f.Config.RulesText
|
||||
embedTitle := "Rules (" + f.Config.Guild.Name + ")"
|
||||
embedTitle := "Rules (" + f.Config.GuildName + ")"
|
||||
embed := f.CreateDefinedEmbed(embedTitle, msg, "success", m.Author)
|
||||
|
||||
_, err := s.ChannelMessageSendEmbed(m.ChannelID, embed)
|
||||
|
@ -579,7 +579,7 @@ func (f *Features) handleUserInfo(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
userSplit := strings.Split(m.Content, " ")
|
||||
|
||||
if len(userSplit) < 2 {
|
||||
mHandle, err = s.GuildMember(f.Config.Guild.ID, m.Author.ID)
|
||||
mHandle, err = s.GuildMember(f.Config.GuildID, m.Author.ID)
|
||||
requester = mHandle
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -588,11 +588,11 @@ func (f *Features) handleUserInfo(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
idStr := strings.ReplaceAll(userSplit[1], "<@!", "")
|
||||
idStr = strings.ReplaceAll(idStr, "<@", "")
|
||||
idStr = strings.ReplaceAll(idStr, ">", "")
|
||||
mHandle, err = s.GuildMember(f.Config.Guild.ID, idStr)
|
||||
mHandle, err = s.GuildMember(f.Config.GuildID, idStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
requester, err = s.GuildMember(f.Config.Guild.ID, m.Author.ID)
|
||||
requester, err = s.GuildMember(f.Config.GuildID, m.Author.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -663,21 +663,28 @@ func (f *Features) handleUserInfo(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
}
|
||||
|
||||
func (f *Features) handleServerInfo(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
sID := f.Config.Guild.ID
|
||||
sName := f.Config.Guild.Name
|
||||
sChannels := strconv.Itoa(len(f.Config.Guild.Channels))
|
||||
sEmojis := strconv.Itoa(len(f.Config.Guild.Emojis))
|
||||
sMembers := strconv.Itoa(f.Config.Guild.MemberCount)
|
||||
sRoles := strconv.Itoa(len(f.Config.Guild.Roles))
|
||||
sRegion := f.Config.Guild.Region
|
||||
sJoinedAt, _ := f.Config.Guild.JoinedAt.Parse()
|
||||
sIconURL := f.Config.Guild.IconURL()
|
||||
g, err := s.Guild(f.Config.GuildID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sID := f.Config.GuildID
|
||||
sName := f.Config.GuildName
|
||||
|
||||
chans, _ := s.GuildChannels(f.Config.GuildID)
|
||||
sChannels := strconv.Itoa(len(chans))
|
||||
|
||||
sEmojis := strconv.Itoa(len(g.Emojis))
|
||||
|
||||
sRoles := strconv.Itoa(len(g.Roles))
|
||||
sRegion := g.Region
|
||||
sJoinedAt, _ := g.JoinedAt.Parse()
|
||||
sIconURL := g.IconURL()
|
||||
|
||||
user := m.Author
|
||||
|
||||
desc := "**Server ID**: `" + sID + "`\n"
|
||||
desc += "**Server Name**: `" + sName + "`\n"
|
||||
desc += "**Server Members**: `" + sMembers + "`\n"
|
||||
desc += "**Server Channels**: `" + sChannels + "`\n"
|
||||
desc += "**Server Emojis**: `" + sEmojis + "`\n"
|
||||
desc += "**Server Roles**: `" + sRoles + "`\n"
|
||||
|
@ -708,7 +715,7 @@ func (f *Features) handleServerInfo(s *discordgo.Session, m *discordgo.MessageCr
|
|||
|
||||
msg := f.CreateCustomEmbed(&embedData)
|
||||
|
||||
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
|
||||
_, err = s.ChannelMessageSendEmbed(m.ChannelID, msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ func (f *Features) handleKickUser(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
idStr := strings.ReplaceAll(member, "<@!", "")
|
||||
idStr = strings.ReplaceAll(idStr, "<@", "")
|
||||
idStr = strings.ReplaceAll(idStr, ">", "")
|
||||
mHandle, err = s.GuildMember(f.Config.Guild.ID, idStr)
|
||||
mHandle, err = s.GuildMember(f.Config.GuildID, idStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = s.GuildMemberDeleteWithReason(f.Config.Guild.ID, mHandle.User.ID, kickReason)
|
||||
err = s.GuildMemberDeleteWithReason(f.Config.GuildID, mHandle.User.ID, kickReason)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ func (f *Features) handleBanUser(s *discordgo.Session, m *discordgo.MessageCreat
|
|||
return err
|
||||
}
|
||||
|
||||
err = s.GuildBanCreateWithReason(f.Config.Guild.ID, mHandle.ID, banReason, 0)
|
||||
err = s.GuildBanCreateWithReason(f.Config.GuildID, mHandle.ID, banReason, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package models
|
||||
|
||||
import discordgo "github.com/bwmarrin/discord.go"
|
||||
|
||||
type ColorRole struct {
|
||||
Name string `json:"color"`
|
||||
ID string `json:"id"`
|
||||
|
@ -22,7 +20,8 @@ type CommandRestriction struct {
|
|||
type Configuration struct {
|
||||
CommandKey string `json:"command_key"`
|
||||
|
||||
GuildID string `json:"guild_id"`
|
||||
GuildID string `json:"guild_id"`
|
||||
GuildName string `json:"guild_name"`
|
||||
|
||||
StatusText string `json:"status_text"`
|
||||
WelcomeText string `json:"welcome_text"`
|
||||
|
@ -40,6 +39,5 @@ type Configuration struct {
|
|||
|
||||
LoggingChannel string `json:"logging_channel"`
|
||||
|
||||
Guild *discordgo.Guild
|
||||
ConfigPath string
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ type AdminRole struct {
|
|||
type Permissions struct {
|
||||
AdminRoles []AdminRole
|
||||
CommandRestrictions []models.CommandRestriction
|
||||
Guild *discordgo.Guild
|
||||
|
||||
Config *models.Configuration
|
||||
}
|
||||
|
@ -49,7 +48,6 @@ func New(config *models.Configuration, guild *discordgo.Guild) *Permissions {
|
|||
AdminRoles: ars,
|
||||
CommandRestrictions: crs,
|
||||
Config: config,
|
||||
Guild: guild,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue