Merge branch 'slash-commands' of https://github.com/Navy-gif/New-Gbot into slash-commands
This commit is contained in:
commit
46f0ba733b
@ -4,7 +4,6 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const Util = require('../Util.js');
|
||||
const { runInThisContext } = require('vm');
|
||||
|
||||
const Constants = {
|
||||
Types: [
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { Client } = require('discord.js');
|
||||
|
||||
const { Logger, Intercom, EventHooker, LocaleLoader, Registry, Dispatcher, Resolver } = require('./client/');
|
||||
const { Observer, Command } = require('./interfaces/');
|
||||
const { Observer, Command, Setting } = require('./interfaces/');
|
||||
const StorageManager = require('./storage/StorageManager.js');
|
||||
|
||||
const { DefaultGuild } = require('../constants/');
|
||||
|
@ -0,0 +1,96 @@
|
||||
const { InteractionCollector } = require('discord.js');
|
||||
|
||||
const { SlashCommand, CommandOption } = require('../../../interfaces/');
|
||||
|
||||
class SettingCommand extends SlashCommand {
|
||||
|
||||
constructor(client) {
|
||||
|
||||
super(client, {
|
||||
name: 'setting',
|
||||
description: "[DEV] Invoke to display a settings menu.",
|
||||
module: 'administration',
|
||||
options: [
|
||||
new CommandOption({
|
||||
name: 'category',
|
||||
description: "Select a category to view settings for.",
|
||||
type: 'STRING',
|
||||
choices: [
|
||||
{
|
||||
name: 'Administration',
|
||||
value: 'administrator'
|
||||
},
|
||||
{
|
||||
name: 'Moderation',
|
||||
value: 'moderation'
|
||||
},
|
||||
{
|
||||
name: 'Utility',
|
||||
value: 'utility'
|
||||
}
|
||||
],
|
||||
required: true
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async execute(thing, options) {
|
||||
|
||||
const settings = this.client.registry.components
|
||||
.filter((c) => c._type === 'setting' && c.module.name === options.category.value)
|
||||
|
||||
if(settings.size === 0) {
|
||||
return thing.reply({ content: "Could not find any settings in that category." });
|
||||
}
|
||||
|
||||
const selectMenu = {
|
||||
type: 'SELECT_MENU',
|
||||
custom_id: 'setting', //eslint-disable-line camelcase
|
||||
placeholder: 'Settings',
|
||||
options: settings.map((s) => {
|
||||
return {
|
||||
label: s.display,
|
||||
value: s.name,
|
||||
description: s.description,
|
||||
emoji: s.emoji
|
||||
};
|
||||
})
|
||||
};
|
||||
|
||||
const message = await thing.reply({
|
||||
content: 'Choose a setting.',
|
||||
components: [
|
||||
{
|
||||
type: 'ACTION_ROW',
|
||||
components: [
|
||||
selectMenu
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
new InteractionCollector(this.client, {
|
||||
channel: thing.channel,
|
||||
message
|
||||
}).on('collect', (interaction) => {
|
||||
if(interaction.componentType === 'SELECT_MENU' && interaction.customId === 'setting') {
|
||||
const setting = this.client.registry.components.get(`setting:${interaction.values[0]}`);
|
||||
return setting.takeItFromHere(thing, selectMenu);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// console.log(this.module);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SettingCommand;
|
@ -9,12 +9,99 @@ class SettingsCommand extends SlashCommand {
|
||||
module: 'administration',
|
||||
options: [
|
||||
new CommandOption({
|
||||
name: 'category',
|
||||
description: "Select a category to view settings for.",
|
||||
name: 'moderation',
|
||||
description: '',
|
||||
type: 'SUB_COMMAND_GROUP',
|
||||
options: [
|
||||
new CommandOption({
|
||||
type: 'SUB_COMMAND'
|
||||
name: 'wordfilter',
|
||||
description: '',
|
||||
type: 'SUB_COMMAND',
|
||||
options: [
|
||||
new CommandOption({
|
||||
name: 'option',
|
||||
description: '',
|
||||
required: true,
|
||||
type: 'STRING',
|
||||
choices: [{
|
||||
name: 'fuzzy', value: 'fuzzy'
|
||||
}, {
|
||||
name: 'explicit', value: 'explicit'
|
||||
}, {
|
||||
name: 'regex', value: 'regex'
|
||||
}]
|
||||
}),
|
||||
new CommandOption({
|
||||
name: 'value',
|
||||
description: '',
|
||||
required: true,
|
||||
type: 'STRING'
|
||||
}),
|
||||
new CommandOption({
|
||||
name: 'method',
|
||||
description: '',
|
||||
required: false,
|
||||
type: 'STRING',
|
||||
choices: [{
|
||||
name: 'add',
|
||||
value: 'add'
|
||||
}, {
|
||||
name: 'delete',
|
||||
value: 'delete'
|
||||
}, {
|
||||
name: 'set',
|
||||
value: 'set'
|
||||
}, {
|
||||
name: 'reset',
|
||||
value: 'reset'
|
||||
}]
|
||||
})
|
||||
]
|
||||
}),
|
||||
new CommandOption({
|
||||
name: 'linkfilter',
|
||||
description: '',
|
||||
type: 'SUB_COMMAND',
|
||||
options: [
|
||||
new CommandOption({
|
||||
name: 'option',
|
||||
description: '',
|
||||
required: true,
|
||||
type: 'STRING',
|
||||
choices: [{
|
||||
name: 'fuzzy', value: 'fuzzy'
|
||||
}, {
|
||||
name: 'explicit', value: 'explicit'
|
||||
}, {
|
||||
name: 'regex', value: 'regex'
|
||||
}]
|
||||
}),
|
||||
new CommandOption({
|
||||
name: 'method',
|
||||
description: '',
|
||||
required: false,
|
||||
type: 'STRING',
|
||||
choices: [{
|
||||
name: 'add',
|
||||
value: 'add'
|
||||
}, {
|
||||
name: 'delete',
|
||||
value: 'delete'
|
||||
}, {
|
||||
name: 'set',
|
||||
value: 'set'
|
||||
}, {
|
||||
name: 'reset',
|
||||
value: 'reset'
|
||||
}]
|
||||
}),
|
||||
new CommandOption({
|
||||
name: 'value',
|
||||
description: '',
|
||||
required: false,
|
||||
type: 'STRING'
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
})
|
||||
@ -23,6 +110,11 @@ class SettingsCommand extends SlashCommand {
|
||||
});
|
||||
}
|
||||
|
||||
// /settings moderation mute method:role submethod:something more value:something
|
||||
// / settings moderation mute method: length value: something
|
||||
|
||||
// / settings moderation wordfilter option: fuzzy method: add value: word1 word2 word3
|
||||
|
||||
async execute(thing, options) {
|
||||
|
||||
|
||||
|
@ -6,7 +6,91 @@ class MuteSetting extends Setting {
|
||||
|
||||
super(client, {
|
||||
name: 'mute',
|
||||
description: 'uhhhhh'
|
||||
description: 'Assign a mute role or configure mute type.',
|
||||
module: 'moderation',
|
||||
display: 'Mute',
|
||||
emoji: {
|
||||
name: 'muted',
|
||||
id: '853709118988353556'
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async takeItFromHere(thing, selectMenu) {
|
||||
|
||||
// console.log(message);
|
||||
|
||||
selectMenu.options.find((o) => o.value === this.name).default = true;
|
||||
|
||||
thing.interaction.editReply({
|
||||
components: [
|
||||
{
|
||||
type: 'ACTION_ROW',
|
||||
components: [
|
||||
selectMenu
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'ACTION_ROW',
|
||||
components: [
|
||||
{
|
||||
type: 'BUTTON',
|
||||
label: 'Mute Type',
|
||||
custom_id: 'null',
|
||||
style: 'SECONDARY',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
type: 'BUTTON',
|
||||
label: 'Addition',
|
||||
custom_id: '0',
|
||||
style: 'SUCCESS'
|
||||
},
|
||||
{
|
||||
type: 'BUTTON',
|
||||
label: 'Mutually Exclusive',
|
||||
custom_id: '1',
|
||||
style: 'SECONDARY'
|
||||
},
|
||||
{
|
||||
type: 'BUTTON',
|
||||
label: 'Subtraction',
|
||||
custom_id: '2',
|
||||
style: 'SECONDARY'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'ACTION_ROW',
|
||||
components: [
|
||||
// {
|
||||
// type: 'BUTTON',
|
||||
// label: 'Mute Role',
|
||||
// custom_id: 'null',
|
||||
// style: 'PRIMARY',
|
||||
// disabled: true
|
||||
// },
|
||||
{
|
||||
type: 'SELECT_MENU',
|
||||
custom_id: 'role',
|
||||
placeholder: 'Role',
|
||||
options: thing.guild.roles.cache.map((r) => {
|
||||
return {
|
||||
label: r.name,
|
||||
value: r.id,
|
||||
emoji: {
|
||||
name: 'role',
|
||||
id: '743563678292639794'
|
||||
}
|
||||
};
|
||||
}),
|
||||
minValues: 1,
|
||||
maxValues: thing.guild.roles.cache.size
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
const { Setting } = require('../../../interfaces/');
|
||||
|
||||
class WordFilterSetting extends Setting {
|
||||
|
||||
constructor(client) {
|
||||
|
||||
super(client, {
|
||||
name: 'wordfilter',
|
||||
description: 'Configure words for the word filter, etc.',
|
||||
module: 'moderation',
|
||||
display: 'Word Filter',
|
||||
emoji: {
|
||||
name: 'news',
|
||||
id: '741725913171099810'
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async execute(thing, options) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = WordFilterSetting;
|
@ -17,6 +17,9 @@ class Setting extends Component {
|
||||
|
||||
this.description = options.description || "";
|
||||
|
||||
this.display = options.display || options.name;
|
||||
this.emoji = options.emoji || {};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class Thing {
|
||||
// delete options.emoji;
|
||||
}
|
||||
|
||||
this._pending = this.interaction.reply(options);
|
||||
this._pending = await this.interaction.reply(options);
|
||||
return this._pending;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user