This commit is contained in:
parent
4895294969
commit
964be05c48
@ -39,6 +39,7 @@ func addModeratorRoleCommandFunc(ctx disgoman.Context, args []string) {
|
|||||||
}
|
}
|
||||||
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
|
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
|
||||||
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
|
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
|
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
|
||||||
ID: id,
|
ID: id,
|
||||||
@ -88,6 +89,7 @@ func addAdminRoleCommandFunc(ctx disgoman.Context, args []string) {
|
|||||||
}
|
}
|
||||||
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
|
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
|
||||||
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
|
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
|
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
|
||||||
ID: id,
|
ID: id,
|
||||||
@ -107,3 +109,53 @@ func addAdminRoleCommandFunc(ctx disgoman.Context, args []string) {
|
|||||||
_, _ = ctx.Send("Please include at least one role to make an admin role.")
|
_, _ = ctx.Send("Please include at least one role to make an admin role.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var RemoveModRoleCommand = &disgoman.Command{
|
||||||
|
Name: "removeMod",
|
||||||
|
Aliases: []string{"removeModeratorRole", "removeModRole", "removeAdmin", "removeAdminRole"},
|
||||||
|
Description: "Remove a role or several roles from the moderator or admin list",
|
||||||
|
OwnerOnly: false,
|
||||||
|
Hidden: false,
|
||||||
|
RequiredPermissions: disgoman.PermissionManageServer,
|
||||||
|
Invoke: removeModRoleCommandFunc,
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeModRoleCommandFunc(ctx disgoman.Context, args []string) {
|
||||||
|
var count int
|
||||||
|
added := make(map[string]bool)
|
||||||
|
guild, err := services.GuildService.GetOrCreateGuild(ctx.Guild.ID)
|
||||||
|
if err != nil {
|
||||||
|
discord_utils.SendErrorMessage(ctx, "Something went wrong getting the guild", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
roles := append(args, ctx.Message.MentionRoles...)
|
||||||
|
if len(roles) > 0 {
|
||||||
|
for _, id := range roles {
|
||||||
|
if strings.HasPrefix(id, "<@&") && strings.HasSuffix(id, ">") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := added[id]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
|
||||||
|
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
|
||||||
|
ID: id,
|
||||||
|
RoleType: "normal",
|
||||||
|
Guild: guild,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
discord_utils.SendErrorMessage(ctx, fmt.Sprintf("There was a problem adding <@&%s>", id), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
added[id] = true
|
||||||
|
count++
|
||||||
|
_, _ = ctx.Send(fmt.Sprintf("Set <@&%s> as a normal role.", id))
|
||||||
|
}
|
||||||
|
_, _ = ctx.Send(fmt.Sprintf("Set %d roles to normal.", count))
|
||||||
|
} else {
|
||||||
|
_, _ = ctx.Send("Please include at least one role to remove from the moderator or admin lists.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -26,5 +26,6 @@ func AddCommandHandlers(g *disgoman.CommandManager) {
|
|||||||
_ = g.AddCommand(guild.RemovePrefixCommand)
|
_ = g.AddCommand(guild.RemovePrefixCommand)
|
||||||
_ = g.AddCommand(guild.AddModeratorRoleCommand)
|
_ = g.AddCommand(guild.AddModeratorRoleCommand)
|
||||||
_ = g.AddCommand(guild.AddAdminRoleCommand)
|
_ = g.AddCommand(guild.AddAdminRoleCommand)
|
||||||
|
_ = g.AddCommand(guild.RemoveModRoleCommand)
|
||||||
_ = g.AddCommand(requests.RequestCommand)
|
_ = g.AddCommand(requests.RequestCommand)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user