mirror of
https://github.com/DarthKilroy/Spot.git
synced 2025-12-19 02:06:48 +00:00
de-OOPify stuff a little
This commit is contained in:
parent
c3fa0554c4
commit
2aadc1a1ef
6 changed files with 30 additions and 89 deletions
|
|
@ -1,23 +1,14 @@
|
|||
const Logger = require('@lilywonhalf/pretty-logger');
|
||||
const Discord = require('discord.js');
|
||||
const CommandCategory = require('../model/command-category');
|
||||
const CommandPermission = require('../model/command-permission');
|
||||
const Guild = require('../model/guild');
|
||||
|
||||
class Avatar
|
||||
{
|
||||
constructor() {
|
||||
this.aliases = ['av'];
|
||||
this.category = CommandCategory.FUN;
|
||||
this.isAllowedForContext = CommandPermission.yes;
|
||||
this.description = 'Displays the avatar of the specified member.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
* @param {Array} args
|
||||
*/
|
||||
async process(message, args) {
|
||||
module.exports = {
|
||||
aliases: ['av'],
|
||||
category: CommandCategory.FUN,
|
||||
isAllowedForContext: () => true,
|
||||
description: 'Displays the avatar of the specified member.',
|
||||
process: async (message, args) => {
|
||||
let user = null;
|
||||
|
||||
if (args.length > 0) {
|
||||
|
|
@ -46,5 +37,3 @@ class Avatar
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Avatar();
|
||||
|
|
|
|||
|
|
@ -6,20 +6,13 @@ const { search } = require('../model/jira');
|
|||
|
||||
const MAX_CHARACTERS = 1950;
|
||||
|
||||
class Changelog
|
||||
{
|
||||
constructor() {
|
||||
this.aliases = ['change-log', 'cl'];
|
||||
this.category = CommandCategory.MODERATION;
|
||||
this.isAllowedForContext = CommandPermission.isMemberMod;
|
||||
this.description = 'Builds the changelog for a given version';
|
||||
}
|
||||
module.exports = {
|
||||
aliases: ['change-log', 'cl'],
|
||||
category: CommandCategory.MODERATION,
|
||||
isAllowedForContext: CommandPermission.isMemberMod,
|
||||
description: 'Builds the changelog for a given version',
|
||||
process: async (message, args) => {
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
* @param {Array} args
|
||||
*/
|
||||
async process(message, args) {
|
||||
const errorHandler = async (error) => {
|
||||
if (error) {
|
||||
Logger.exception(error);
|
||||
|
|
@ -71,5 +64,3 @@ class Changelog
|
|||
await message.react('✔').catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Changelog();
|
||||
|
|
|
|||
|
|
@ -1,22 +1,13 @@
|
|||
const Logger = require('@lilywonhalf/pretty-logger');
|
||||
const Config = require('../config.json');
|
||||
const CommandCategory = require('../model/command-category');
|
||||
const CommandPermission = require('../model/command-permission');
|
||||
|
||||
class Clean
|
||||
{
|
||||
constructor() {
|
||||
this.aliases = ['clear', 'purge'];
|
||||
this.category = CommandCategory.MODERATION;
|
||||
this.isAllowedForContext = CommandPermission.isMemberMod;
|
||||
this.description = 'Deletes messages in a bulk.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
* @param {Array} args
|
||||
*/
|
||||
async process(message, args) {
|
||||
module.exports = {
|
||||
aliases: ['clear', 'purge'],
|
||||
category: CommandCategory.MODERATION,
|
||||
isAllowedForContext: CommandPermission.isMemberMod,
|
||||
description: 'Deletes messages in bulk.',
|
||||
process: async (message, args) => {
|
||||
if (args.length > 0 && parseInt(args[0]) > 0) {
|
||||
await message.channel.bulkDelete(Math.min(parseInt(args[0]) + 1, 100));
|
||||
} else {
|
||||
|
|
@ -24,5 +15,3 @@ class Clean
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Clean();
|
||||
|
|
|
|||
|
|
@ -9,18 +9,11 @@ const Guild = require('../model/guild');
|
|||
|
||||
const JAVASCRIPT_LOGO_URL = 'https://i.discord.fr/IEV8.png';
|
||||
|
||||
class Eval
|
||||
{
|
||||
constructor() {
|
||||
this.aliases = [];
|
||||
this.category = CommandCategory.BOT_MANAGEMENT;
|
||||
this.isAllowedForContext = CommandPermission.isMommy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
*/
|
||||
async process(message) {
|
||||
module.exports = {
|
||||
aliases: [],
|
||||
category: CommandCategory.BOT_MANAGEMENT,
|
||||
isAllowedForContext: CommandPermission.isMommy,
|
||||
process: async (message) => {
|
||||
const code = message.content
|
||||
.substr(Config.prefix.length + 'eval'.length)
|
||||
.trim()
|
||||
|
|
@ -44,6 +37,4 @@ class Eval
|
|||
|
||||
message.channel.send(embed).catch(error => Logger.warning(error.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Eval();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,21 +81,12 @@ const categoryPage = (cat, id, direct = false) => {
|
|||
return data;
|
||||
}
|
||||
|
||||
class Help
|
||||
{
|
||||
constructor() {
|
||||
this.aliases = ['commands'];
|
||||
this.category = CommandCategory.INFO;
|
||||
this.isAllowedForContext = CommandPermission.yes;
|
||||
this.description = 'Provides the list of commands';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
* @param {Array} args
|
||||
* @param {Command} Command
|
||||
*/
|
||||
async process(message, args, command) {
|
||||
module.exports = {
|
||||
aliases: ["commands"],
|
||||
category: CommandCategory.INFO,
|
||||
isAllowedForContext: () => true,
|
||||
description: 'Provides the list of commands.',
|
||||
process: async (message, args) => {
|
||||
if (!args[0])
|
||||
await bot.api.channels(message.channel.id).messages.post({ data: mainPage(message.author.id) });
|
||||
else
|
||||
|
|
@ -111,8 +102,6 @@ class Help
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = new Help();
|
||||
|
||||
module.exports.interactionHandler = async (event) => {
|
||||
const user = event.member ? event.member.user.id : event.user.id;
|
||||
const customId = event.data.custom_id;
|
||||
|
|
|
|||
|
|
@ -31,14 +31,6 @@ const CommandPermission = {
|
|||
|
||||
return await CommandPermission.isMemberMod(message) || await Guild.isMemberHelper(member);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Message} message
|
||||
* @returns {Promise.<boolean>}
|
||||
*/
|
||||
yes: async (message) => {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CommandPermission;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue