-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
251 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/bwmarrin/discordgo" | ||
"github.com/zekroTJA/shinpuru/util" | ||
) | ||
|
||
type CmdBan struct { | ||
} | ||
|
||
func (c *CmdBan) GetInvokes() []string { | ||
return []string{"ban", "userban"} | ||
} | ||
|
||
func (c *CmdBan) GetDescription() string { | ||
return "ban users with creating a report entry" | ||
} | ||
|
||
func (c *CmdBan) GetHelp() string { | ||
return "`ban <UserResolvable> <Reason>`" | ||
} | ||
|
||
func (c *CmdBan) GetGroup() string { | ||
return GroupModeration | ||
} | ||
|
||
func (c *CmdBan) GetPermission() int { | ||
return 8 | ||
} | ||
|
||
func (c *CmdBan) Exec(args *CommandArgs) error { | ||
if len(args.Args) < 2 { | ||
msg, err := util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Invalid command arguments. Please use `help ban` to see how to use this command.") | ||
util.DeleteMessageLater(args.Session, msg, 8*time.Second) | ||
return err | ||
} | ||
victim, err := util.FetchMember(args.Session, args.Guild.ID, args.Args[0]) | ||
if err != nil || victim == nil { | ||
msg, err := util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Sorry, could not find any member :cry:") | ||
util.DeleteMessageLater(args.Session, msg, 10*time.Second) | ||
return err | ||
} | ||
|
||
repMsg := strings.Join(args.Args[1:], " ") | ||
var repType int | ||
for i, v := range util.ReportTypes { | ||
if v == "BAN" { | ||
repType = i | ||
} | ||
} | ||
repID := util.ReportNodes[repType].Generate() | ||
|
||
acceptMsg := util.AcceptMessage{ | ||
Embed: &discordgo.MessageEmbed{ | ||
Color: util.ReportColors[repType], | ||
Title: "Ban Check", | ||
Description: "Is everything okay so far?", | ||
Fields: []*discordgo.MessageEmbedField{ | ||
&discordgo.MessageEmbedField{ | ||
Name: "Victim", | ||
Value: fmt.Sprintf("<@%s> (%s#%s)", | ||
victim.User.ID, victim.User.Username, victim.User.Discriminator), | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "ID", | ||
Value: repID.String(), | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "Type", | ||
Value: util.ReportTypes[repType], | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "Description", | ||
Value: repMsg, | ||
}, | ||
}, | ||
}, | ||
Session: args.Session, | ||
UserID: args.User.ID, | ||
DeleteMsgAfter: true, | ||
AcceptFunc: func(msg *discordgo.Message) { | ||
rep := &util.Report{ | ||
ID: repID, | ||
Type: repType, | ||
GuildID: args.Guild.ID, | ||
ExecutorID: args.User.ID, | ||
VictimID: victim.User.ID, | ||
Msg: repMsg, | ||
} | ||
err = args.Session.GuildBanCreateWithReason(args.Guild.ID, victim.User.ID, repMsg, 7) | ||
if err != nil { | ||
util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Failed creating ban: ```\n"+err.Error()+"\n```") | ||
return | ||
} | ||
err = args.CmdHandler.db.AddReport(rep) | ||
if err != nil { | ||
util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Failed creating report: ```\n"+err.Error()+"\n```") | ||
return | ||
} | ||
args.Session.ChannelMessageSendEmbed(args.Channel.ID, rep.AsEmbed()) | ||
if modlogChan, err := args.CmdHandler.db.GetGuildModLog(args.Guild.ID); err == nil { | ||
args.Session.ChannelMessageSendEmbed(modlogChan, rep.AsEmbed()) | ||
} | ||
}, | ||
} | ||
|
||
_, err = acceptMsg.Send(args.Channel.ID) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/bwmarrin/discordgo" | ||
"github.com/zekroTJA/shinpuru/util" | ||
) | ||
|
||
type CmdKick struct { | ||
} | ||
|
||
func (c *CmdKick) GetInvokes() []string { | ||
return []string{"kick", "userkick"} | ||
} | ||
|
||
func (c *CmdKick) GetDescription() string { | ||
return "kick users with creating a report entry" | ||
} | ||
|
||
func (c *CmdKick) GetHelp() string { | ||
return "`kick <UserResolvable> <Reason>`" | ||
} | ||
|
||
func (c *CmdKick) GetGroup() string { | ||
return GroupModeration | ||
} | ||
|
||
func (c *CmdKick) GetPermission() int { | ||
return 6 | ||
} | ||
|
||
func (c *CmdKick) Exec(args *CommandArgs) error { | ||
if len(args.Args) < 2 { | ||
msg, err := util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Invalid command arguments. Please use `help kick` to see how to use this command.") | ||
util.DeleteMessageLater(args.Session, msg, 8*time.Second) | ||
return err | ||
} | ||
victim, err := util.FetchMember(args.Session, args.Guild.ID, args.Args[0]) | ||
if err != nil || victim == nil { | ||
msg, err := util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Sorry, could not find any member :cry:") | ||
util.DeleteMessageLater(args.Session, msg, 10*time.Second) | ||
return err | ||
} | ||
|
||
repMsg := strings.Join(args.Args[1:], " ") | ||
var repType int | ||
for i, v := range util.ReportTypes { | ||
if v == "KICK" { | ||
repType = i | ||
} | ||
} | ||
repID := util.ReportNodes[repType].Generate() | ||
|
||
acceptMsg := util.AcceptMessage{ | ||
Embed: &discordgo.MessageEmbed{ | ||
Color: util.ReportColors[repType], | ||
Title: "Kick Check", | ||
Description: "Is everything okay so far?", | ||
Fields: []*discordgo.MessageEmbedField{ | ||
&discordgo.MessageEmbedField{ | ||
Name: "Victim", | ||
Value: fmt.Sprintf("<@%s> (%s#%s)", | ||
victim.User.ID, victim.User.Username, victim.User.Discriminator), | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "ID", | ||
Value: repID.String(), | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "Type", | ||
Value: util.ReportTypes[repType], | ||
}, | ||
&discordgo.MessageEmbedField{ | ||
Name: "Description", | ||
Value: repMsg, | ||
}, | ||
}, | ||
}, | ||
Session: args.Session, | ||
UserID: args.User.ID, | ||
DeleteMsgAfter: true, | ||
AcceptFunc: func(msg *discordgo.Message) { | ||
rep := &util.Report{ | ||
ID: repID, | ||
Type: repType, | ||
GuildID: args.Guild.ID, | ||
ExecutorID: args.User.ID, | ||
VictimID: victim.User.ID, | ||
Msg: repMsg, | ||
} | ||
err = args.Session.GuildMemberDeleteWithReason(args.Guild.ID, victim.User.ID, repMsg) | ||
if err != nil { | ||
util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Failed kicking member: ```\n"+err.Error()+"\n```") | ||
return | ||
} | ||
err = args.CmdHandler.db.AddReport(rep) | ||
if err != nil { | ||
util.SendEmbedError(args.Session, args.Channel.ID, | ||
"Failed creating report: ```\n"+err.Error()+"\n```") | ||
return | ||
} | ||
args.Session.ChannelMessageSendEmbed(args.Channel.ID, rep.AsEmbed()) | ||
if modlogChan, err := args.CmdHandler.db.GetGuildModLog(args.Guild.ID); err == nil { | ||
args.Session.ChannelMessageSendEmbed(modlogChan, rep.AsEmbed()) | ||
} | ||
}, | ||
} | ||
|
||
_, err = acceptMsg.Send(args.Channel.ID) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters