-
Notifications
You must be signed in to change notification settings - Fork 0
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
16 changed files
with
204 additions
and
58 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 @@ | ||
[] |
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 @@ | ||
{} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { SlashCommandBuilder } from "discord.js"; | ||
import { Command } from "../../lib/command"; | ||
import { Embeds } from "../../utils/embeds"; | ||
import { PermissionLevel, getNameFromPermissionLevel, permissionManager } from "../../lib/permissions"; | ||
|
||
export default <Command>{ | ||
metadata: new SlashCommandBuilder() | ||
.setName('perms') | ||
.setDescription('Changes internal bot permissions for a user') | ||
.addSubcommand(subcommand => subcommand | ||
.setName("set") | ||
.setDescription("Sets a user's permission level") | ||
.addUserOption(option => option.setName("user").setDescription("The user to set the permission level for").setRequired(true)) | ||
.addStringOption(option => option.setName("level") | ||
.setDescription("The permission level to set the user to") | ||
.setChoices(...Object.keys(PermissionLevel).map(level => ({ name: level, value: level }))) | ||
.setRequired(true)) | ||
) | ||
.addSubcommand(subcommand => subcommand | ||
.setName("view") | ||
.setDescription("View a users permission level") | ||
.addUserOption(option => option.setName("user").setDescription("The user to set the permission level for").setRequired(true)) | ||
) | ||
.setDMPermission(false), | ||
permission: PermissionLevel.ADMIN, | ||
execute: async (_, user, interaction) => { | ||
const subcommand = interaction.options.getSubcommand(); | ||
if (subcommand == "set") { | ||
const level = interaction.options.getString("level", true); | ||
const target = interaction.options.getUser("user", true); | ||
const permissionLevel = PermissionLevel[level as keyof typeof PermissionLevel]; | ||
|
||
permissionManager.setPermissionLevel(interaction.guild!.id, target.id, permissionLevel); | ||
|
||
await Embeds.create() | ||
.setTitle("Permission Level") | ||
.setDescription(`${target.toString()}'s permission level has been changed to \`${getNameFromPermissionLevel(permissionLevel)}\``) | ||
.send(interaction); | ||
} else if (subcommand == "view") { | ||
const target = interaction.options.getUser("user", true); | ||
const permissionLevel = permissionManager.getPermissionLevel(interaction.guild!.id, target.id); | ||
|
||
await Embeds.create() | ||
.setTitle("Permission Level") | ||
.setDescription(`${target.toString()}'s permission level is \`${getNameFromPermissionLevel(permissionLevel)}\``) | ||
.send(interaction); | ||
} | ||
}, | ||
} |
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
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
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { Client, SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js"; | ||
import { ChatInputCommandInteraction, Client, GuildMember, SlashCommandBuilder } from "discord.js"; | ||
import { PermissionLevel } from "./permissions"; | ||
|
||
export interface Command { | ||
data: SlashCommandBuilder | Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">; | ||
execute: (client: Client, interaction: ChatInputCommandInteraction) => void; | ||
metadata: SlashCommandBuilder | Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">; | ||
permission?: PermissionLevel; | ||
execute: (client: Client, user: GuildMember, interaction: ChatInputCommandInteraction) => void; | ||
} |
Oops, something went wrong.