mirror of
https://github.com/Wessel/yorushika.git
synced 2026-07-17 22:14:57 +02:00
[refractor 1.3] Even more done!
This commit is contained in:
@@ -24,7 +24,9 @@ info :
|
||||
multi : 0x34363C # Dark
|
||||
single: 0x34363C # Dark
|
||||
|
||||
tags: 0x7289DA # Blurple
|
||||
tag :
|
||||
list: 0x7289DA # Blurple
|
||||
info: 0x7289DA # Blurple
|
||||
|
||||
image :
|
||||
cat : 0x7289DA # Blurple
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = class Locale extends DiscordCommand {
|
||||
syntax : 'locale <locale:code> <-u|-g>',
|
||||
aliases : [],
|
||||
argument : [ '<locale:code>', '-<u|g>' ],
|
||||
description : 'Change your locale',
|
||||
description: 'Change your locale',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
@@ -61,7 +61,7 @@ module.exports = class Locale extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
|
||||
if (extData && extData.uLocale) msg = msg.replace(/\$\[uLocale:code]/g, extData.uLocale);
|
||||
|
||||
@@ -83,7 +83,7 @@ module.exports = class Prefix extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
// Optional replacements
|
||||
if (extData) {
|
||||
|
||||
@@ -74,7 +74,7 @@ module.exports = class Eval extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) return 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ module.exports = class Exec extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = class Splatoon extends DiscordCommand {
|
||||
msg.channel.createMessage(this._localize(msg.author.locale.games.splatoon.join('\n'), res));
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ module.exports = class Avatar extends DiscordCommand {
|
||||
});
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ module.exports = class Commands extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports = class Stats extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = class Guild extends DiscordCommand {
|
||||
});
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ module.exports = class User extends DiscordCommand {
|
||||
'offline' : `${this.bot.emote('info', 'user', '10')}offline`
|
||||
}
|
||||
};
|
||||
|
||||
Object.freeze(this);
|
||||
Object.freeze(this.static);
|
||||
}
|
||||
|
||||
async execute(msg, args) {
|
||||
@@ -84,44 +87,44 @@ module.exports = class User extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
if (extData) {
|
||||
if (extData.user) {
|
||||
const u = extData.user;
|
||||
u.c = moment.preciseDiff(new Date(), new Date(u.createdAt), true);
|
||||
u.cs = [
|
||||
u.c.years >= 1 ? `${u.c.years} years` : undefined,
|
||||
u.c.months >= 1 ? `${u.c.months} months` : undefined,
|
||||
u.c.days >= 1 ? `${u.c.days} days` : undefined,
|
||||
u.c.days <= 0 && u.c.months <= 0 && u.c.years <= 0 ? 'Less than a day' : undefined
|
||||
const { user } = extData;
|
||||
user.c = moment.preciseDiff(new Date(), new Date(user.createdAt), true);
|
||||
user.cs = [
|
||||
user.c.years >= 1 ? `${user.c.years} years` : undefined,
|
||||
user.c.months >= 1 ? `${user.c.months} months` : undefined,
|
||||
user.c.days >= 1 ? `${user.c.days} days` : undefined,
|
||||
user.c.days <= 0 && user.c.months <= 0 && user.c.years <= 0 ? 'Less than a day' : undefined
|
||||
].join(' ');
|
||||
|
||||
msg = msg
|
||||
.replace(/\$\[user:id]/g , u.id)
|
||||
.replace(/\$\[user:tag]/g , `${u.username}#${u.discriminator}`)
|
||||
.replace(/\$\[user:created@exact]/g, moment(u.createdAt).format('YYYY[/]MM[/]DD HH[:]mm'))
|
||||
.replace(/\$\[user:created@precise]/g, u.cs)
|
||||
.replace(/\$\[user:id]/g , user.id)
|
||||
.replace(/\$\[user:tag]/g , `${user.username}#${user.discriminator}`)
|
||||
.replace(/\$\[user:created@exact]/g, moment(user.createdAt).format('YYYY[/]MM[/]DD HH[:]mm'))
|
||||
.replace(/\$\[user:created@precise]/g, user.cs)
|
||||
.replace(/\$\[user:status@full]/g, extData.member && this.static.status[extData.member.status] ? this.static.status[extData.member.status] : this.static.status['_unknown']);
|
||||
}
|
||||
|
||||
if (extData.member) {
|
||||
const m = extData.member;
|
||||
m.c = moment.preciseDiff(new Date(), new Date(m.joinedAt), true);
|
||||
m.cs = [
|
||||
m.c.years >= 1 ? `${m.c.years} years` : undefined,
|
||||
m.c.months >= 1 ? `${m.c.months} months` : undefined,
|
||||
m.c.days >= 1 ? `${m.c.days} days` : undefined,
|
||||
m.c.days <= 0 && m.c.months <= 0 && m.c.years <= 0 ? 'Less than a day' : undefined
|
||||
const { member } = extData;
|
||||
member.c = moment.preciseDiff(new Date(), new Date(member.joinedAt), true);
|
||||
member.cs = [
|
||||
member.c.years >= 1 ? `${member.c.years} years` : undefined,
|
||||
member.c.months >= 1 ? `${member.c.months} months` : undefined,
|
||||
member.c.days >= 1 ? `${member.c.days} days` : undefined,
|
||||
member.c.days <= 0 && member.c.months <= 0 && member.c.years <= 0 ? 'Less than a day' : undefined
|
||||
].join(' ');
|
||||
|
||||
msg = msg
|
||||
.replace(/\$\[member:nickname]/g, m && m.nick ? this.bot.util.escapeMarkdown(m.nick) : '*No nickname set*')
|
||||
.replace(/\$\[member:roles]/g, m.roles.length >= 1 ? this._limit(m.roles.map((v) => `<@&${v}>`), 25).join(' **/** ') : 'none')
|
||||
.replace(/\$\[member:created@exact]/g, moment(m.joinedAt).format('YYYY[/]MM[/]DD HH[:]mm'))
|
||||
.replace(/\$\[member:created@precise]/g, m.cs);
|
||||
.replace(/\$\[member:nickname]/g, member && member.nick ? this.bot.util.escapeMarkdown(member.nick) : '*No nickname set*')
|
||||
.replace(/\$\[member:roles]/g, member.roles.length >= 1 ? this._limit(member.roles.map((v) => `<@&${v}>`), 25).join(' **/** ') : 'none')
|
||||
.replace(/\$\[member:created@exact]/g, moment(member.joinedAt).format('YYYY[/]MM[/]DD HH[:]mm'))
|
||||
.replace(/\$\[member:created@precise]/g, member.cs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
// @TODO: refractor
|
||||
const { DiscordCommand } = require('../../../core');
|
||||
|
||||
const m = require('moment');
|
||||
|
||||
module.exports = class TagAdd extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'tag-add',
|
||||
syntax : 'tag-add <...name:str> | <..content:string>',
|
||||
aliases : [ 'tagadd', 'addtag', 'createtag', 'tagcreate', 'maketag', 'make-tag', 'tag-create' ],
|
||||
argument : [ '<...name:str>', '<..content:string>' ],
|
||||
description : 'Create a tag',
|
||||
name : 'tag-add',
|
||||
syntax : 'tag-add <...name:str> | <..content:string>',
|
||||
aliases : [ 'tagadd', 'addtag', 'createtag', 'tagcreate', 'maketag', 'make-tag', 'tag-create' ],
|
||||
argument : [ '<...name:str>', '<..content:string>' ],
|
||||
description: 'Create a tag',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 1000,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions : []
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 1000,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions: []
|
||||
});
|
||||
}
|
||||
|
||||
async execute(msg, args) {
|
||||
|
||||
let components = args.join(' ').split(/\|/g);
|
||||
let components = args.join(' ').split(/\|/g).filter((v) => { return v.length >= 1 });
|
||||
let mess;
|
||||
let tag = {
|
||||
name : undefined,
|
||||
uses : 0,
|
||||
@@ -41,12 +40,6 @@ module.exports = class TagAdd extends DiscordCommand {
|
||||
}
|
||||
};
|
||||
|
||||
// Delete all empty elements in `components`
|
||||
components = components.filter((v) => {
|
||||
return v.length >= 1;
|
||||
});
|
||||
|
||||
let mess;
|
||||
|
||||
if (!components[0]) {
|
||||
mess = await msg.channel.createMessage(this._localize(msg.author.locale.tags.add.name.join('\n')));
|
||||
@@ -83,21 +76,27 @@ module.exports = class TagAdd extends DiscordCommand {
|
||||
|
||||
entry = new this.bot.schema.tag(tag);
|
||||
await entry.save();
|
||||
msg.channel.createMessage(this._localize(msg.author.locale.tags.add.success, { name: this.bot.util.escapeMarkdown(tag.name) }));
|
||||
msg.channel.createMessage(this._localize(msg.author.locale.tags.add.success, this.bot.util.escapeMarkdown(tag.name)));
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData.name);
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData);
|
||||
}
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'add', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'add', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'add', '2'))
|
||||
.replace(/\$\[emoji#3]/g, this.bot.emote('tags', 'add', '3'))
|
||||
.replace(/\$\[emoji#4]/g, this.bot.emote('tags', 'add', '4'))
|
||||
.replace(/\$\[emoji#5]/g, this.bot.emote('tags', 'add', '5'))
|
||||
.replace(/\$\[emoji#6]/g, this.bot.emote('tags', 'add', '6'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'add', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'add', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'add', '2'))
|
||||
.replace(/\$\[emoji#3]/g, this.bot.emote('tags', 'add', '3'))
|
||||
.replace(/\$\[emoji#4]/g, this.bot.emote('tags', 'add', '4'))
|
||||
.replace(/\$\[emoji#5]/g, this.bot.emote('tags', 'add', '5'))
|
||||
.replace(/\$\[emoji#6]/g, this.bot.emote('tags', 'add', '6'));
|
||||
}
|
||||
};
|
||||
@@ -3,20 +3,23 @@ const { DiscordCommand } = require('../../../core');
|
||||
module.exports = class TagDel extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'tag-del',
|
||||
syntax : 'tag-del <...tag:str>',
|
||||
aliases : [ 'tagdel', 'deltag', 'tagdelete', 'deletetag', 'del-tag', 'tag-delete', 'delete-tag' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description : 'Delete a tag',
|
||||
name : 'tag-del',
|
||||
syntax : 'tag-del <...tag:str>',
|
||||
aliases : [ 'tagdel', 'deltag', 'tagdelete', 'deletetag', 'del-tag', 'tag-delete', 'delete-tag' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description: 'Delete a tag',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions : []
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions: []
|
||||
});
|
||||
|
||||
Object.freeze(this);
|
||||
Object.freeze(this.static);
|
||||
}
|
||||
|
||||
async execute(msg, args) {
|
||||
@@ -31,17 +34,17 @@ module.exports = class TagDel extends DiscordCommand {
|
||||
return msg.channel.createMessage(this._localize(msg.author.locale.tags.delete.perms));
|
||||
}
|
||||
|
||||
const mess = await msg.channel.createMessage(this._localize(msg.author.locale.tags.delete.confirm.join('\n'), { name: tag.name.replace(/`/g, '`\u200b') }));
|
||||
const mess = await msg.channel.createMessage(this._localize(msg.author.locale.tags.delete.confirm.join('\n'), tag.name.replace(/`/g, '`\u200b')));
|
||||
const res = await this.bot.collector.awaitMessage(msg.channel.id, msg.author.id, 30e3);
|
||||
|
||||
if (res && res.content.toLowerCase() === 'y' || res.content.toLowerCase() === 'ye' || res.content.toLowerCase() === 'yes') {
|
||||
if (mess) mess.edit(this._localize(msg.author.locale.tags.delete.busy, { name: tag.name.replace(/`/g, '`\u200b') }));
|
||||
if (mess) mess.edit(this._localize(msg.author.locale.tags.delete.busy, tag.name.replace(/`/g, '`\u200b')));
|
||||
this.bot.m.connection.collection('dTags').deleteOne({ name: tag.name, 'author.guild': msg.channel.guild.id });
|
||||
if (mess) {
|
||||
mess.delete().catch(() => { return; });
|
||||
}
|
||||
|
||||
msg.channel.createMessage(this._localize(msg.author.locale.tags.delete.done, { name: this.bot.util.escapeMarkdown(tag.name) }));
|
||||
msg.channel.createMessage(this._localize(msg.author.locale.tags.delete.done, this.bot.util.escapeMarkdown(tag.name)));
|
||||
} else {
|
||||
if (mess) {
|
||||
return mess.edit(this._localize(msg.author.locale.cancelled));
|
||||
@@ -49,12 +52,17 @@ module.exports = class TagDel extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData.name);
|
||||
}
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
return msg
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData);
|
||||
}
|
||||
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'del', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'del', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'del', '2'))
|
||||
@@ -62,5 +70,8 @@ module.exports = class TagDel extends DiscordCommand {
|
||||
.replace(/\$\[emoji#4]/g, this.bot.emote('tags', 'del', '4'))
|
||||
.replace(/\$\[emoji#5]/g, this.bot.emote('tags', 'del', '5'))
|
||||
.replace(/\$\[emoji#6]/g, this.bot.emote('tags', 'del', '6'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -9,7 +9,7 @@ module.exports = class TagInfo extends DiscordCommand {
|
||||
syntax : 'tag-info <...tag:str>',
|
||||
aliases : [],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description : 'Info about a tag',
|
||||
description: 'Info about a tag',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
@@ -20,9 +20,12 @@ module.exports = class TagInfo extends DiscordCommand {
|
||||
permissions : []
|
||||
});
|
||||
|
||||
this.mutable = {
|
||||
this.static = {
|
||||
MAX_INT32: 2147483647
|
||||
};
|
||||
|
||||
Object.freeze(this);
|
||||
Object.freeze(this.static);
|
||||
}
|
||||
|
||||
async execute(msg, args) {
|
||||
@@ -33,31 +36,34 @@ module.exports = class TagInfo extends DiscordCommand {
|
||||
|
||||
msg.channel.createMessage({
|
||||
embed: {
|
||||
description: this._localize(msg.author.locale.tags.info.join('\n'), { tag: tag })
|
||||
color: this.bot.col.tag.info,
|
||||
description: this._localize(msg.author.locale.tags.info.join('\n'), tag)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
if (extData) {
|
||||
if (extData.tag) {
|
||||
msg = msg
|
||||
.replace(/\$\[tag:name]/g, this.bot.util.escapeMarkdown(extData.tag.name))
|
||||
.replace(/\$\[tag:uses]/g, extData.tag.uses)
|
||||
.replace(/\$\[tag:history]/g, extData.tag.history.splice(0, 10).join('\n'))
|
||||
.replace(/\$\[tag:creation]/g, moment(new Date(extData.tag.creation)).format('DD[-]MM[-]YYYY HH[:]mm[:]ss'))
|
||||
.replace(/\$\[tag:creator#tag]/g, this.bot.util.escapeMarkdown(`${extData.tag.author.name}#${extData.tag.author.discrim}`));
|
||||
}
|
||||
msg = msg
|
||||
.replace(/\$\[tag:name]/g, this.bot.util.escapeMarkdown(extData.name))
|
||||
.replace(/\$\[tag:uses]/g, extData.uses)
|
||||
.replace(/\$\[tag:history]/g, extData.history.splice(0, 10).join('\n'))
|
||||
.replace(/\$\[tag:creation]/g, moment(new Date(extData.creation)).format('DD[-]MM[-]YYYY HH[:]mm[:]ss'))
|
||||
.replace(/\$\[tag:creator#tag]/g, this.bot.util.escapeMarkdown(`${extData.author.name}#${extData.author.discrim}`));
|
||||
}
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'info', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'info', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'info', '2'))
|
||||
.replace(/\$\[emoji#3]/g, this.bot.emote('tags', 'info', '3'))
|
||||
.replace(/\$\[emoji#4]/g, this.bot.emote('tags', 'info', '4'))
|
||||
.replace(/\$\[emoji#5]/g, this.bot.emote('tags', 'info', '5'));
|
||||
} catch (ex) {}
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'info', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'info', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'info', '2'))
|
||||
.replace(/\$\[emoji#3]/g, this.bot.emote('tags', 'info', '3'))
|
||||
.replace(/\$\[emoji#4]/g, this.bot.emote('tags', 'info', '4'))
|
||||
.replace(/\$\[emoji#5]/g, this.bot.emote('tags', 'info', '5'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,20 +3,23 @@ const { DiscordCommand } = require('../../../core');
|
||||
module.exports = class TagSource extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'tag-source',
|
||||
syntax : 'tag-source <...tag:str>',
|
||||
aliases : [ 'tagsource', 'tagsrc', 'tag-src' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description : 'Source of a tag',
|
||||
name : 'tag-source',
|
||||
syntax : 'tag-source <...tag:str>',
|
||||
aliases : [ 'tagsource', 'tagsrc', 'tag-src' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description: 'Source of a tag',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions : []
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions: []
|
||||
});
|
||||
|
||||
Object.freeze(this);
|
||||
Object.freeze(this.static);
|
||||
}
|
||||
|
||||
async execute(msg, args) {
|
||||
@@ -25,16 +28,22 @@ module.exports = class TagSource extends DiscordCommand {
|
||||
return msg.channel.createMessage(this._localize(msg.author.locale.tags.exec));
|
||||
}
|
||||
|
||||
msg.channel.createMessage(this.bot.util.shorten(this._localize(msg.author.locale.tags.source, tag), 1950));
|
||||
msg.channel.createMessage(this.bot.util.shorten(this._localize(msg.author.locale.tags.source, tag), 2000));
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData.name.replace(/`/g, '`\u200b')).replace(/\$\[tag:content]/g, extData.content.replace(/`/g, '`\u200b'));
|
||||
}
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
return msg
|
||||
if (extData) {
|
||||
msg = msg.replace(/\$\[tag:name]/g, extData.name.replace(/`/g, '`\u200b')).replace(/\$\[tag:content]/g, extData.content.replace(/`/g, '`\u200b'));
|
||||
}
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'source', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'source', '1'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,22 +3,22 @@ const { DiscordCommand } = require('../../../core');
|
||||
module.exports = class Tag extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'tag',
|
||||
syntax : 'tag <...tag:str>',
|
||||
aliases : [ 'show-tag', 'disp-tag' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description : 'Display a tag',
|
||||
name : 'tag',
|
||||
syntax : 'tag <...tag:str>',
|
||||
aliases : [ 'show-tag', 'disp-tag' ],
|
||||
argument : [ '<...tag:str>' ],
|
||||
description: 'Display a tag',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions : []
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions: []
|
||||
});
|
||||
|
||||
this.mutable = {
|
||||
this.static = {
|
||||
MAX_INT32: 2147483647
|
||||
};
|
||||
}
|
||||
@@ -30,10 +30,16 @@ module.exports = class Tag extends DiscordCommand {
|
||||
}
|
||||
|
||||
msg.channel.createMessage(tag.content);
|
||||
this.bot.m.connection.collection('dTags').findOneAndUpdate({ name: tag.name, 'author.guild': msg.channel.guild.id }, { $set: { uses: tag.uses < this.mutable.MAX_INT32 ? +1 : this.mutable.MAX_INT32 } });
|
||||
this.bot.m.connection.collection('dTags').findOneAndUpdate({ name: tag.name, 'author.guild': msg.channel.guild.id }, { $set: { uses: tag.uses < this.static.MAX_INT32 ? tag.uses + 1 : this.static.MAX_INT32 } });
|
||||
}
|
||||
|
||||
_localize(msg) {
|
||||
return msg.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'exec'));
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
return msg.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'exec'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -6,23 +6,23 @@ const { table } = require('table');
|
||||
module.exports = class Tags extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'tags',
|
||||
syntax : 'tags',
|
||||
aliases : [],
|
||||
argument : [],
|
||||
description : 'A list of all tags',
|
||||
name : 'tags',
|
||||
syntax : 'tags',
|
||||
aliases : [],
|
||||
argument : [],
|
||||
description: 'A list of all tags',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions : []
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 2500,
|
||||
category : 'Tags',
|
||||
ownerOnly : false,
|
||||
guildOnly : true,
|
||||
permissions: []
|
||||
});
|
||||
|
||||
this.mutable = {
|
||||
LIMIT: 35,
|
||||
this.static = {
|
||||
limit: 35,
|
||||
BASE_URL: 'https://hastebin.com',
|
||||
TABLE_CONFIG: {
|
||||
border: {
|
||||
@@ -50,6 +50,9 @@ module.exports = class Tags extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Object.freeze(this);
|
||||
Object.freeze(this.static);
|
||||
}
|
||||
|
||||
async execute(msg) {
|
||||
@@ -61,46 +64,52 @@ module.exports = class Tags extends DiscordCommand {
|
||||
}
|
||||
|
||||
const extData = {
|
||||
tags: Array.list(tags.map((v) => `${this.bot.util.escapeMarkdown(v.name)} (\`${v.uses}\`)`).slice(0, this.mutable.LIMIT), '**,** ', '**and** '),
|
||||
tags: Array.list(tags.map((v) => `${this.bot.util.escapeMarkdown(v.name)} (\`${v.uses}\`)`).slice(0, this.static.limit), '**,** ', '**and** '),
|
||||
guild: msg.channel.guild.name
|
||||
};
|
||||
|
||||
if (tags.length > this.mutable.LIMIT) {
|
||||
if (tags.length > this.static.limit) {
|
||||
tags.map((v) => data.push([ v.name, `${v.author.name}#${v.author.discrim}`, v.uses ]));
|
||||
|
||||
let res = await w(`${this.mutable.BASE_URL}/documents`, { method: 'POST', data: table(data, this.mutable.TABLE_CONFIG) }).send();
|
||||
res = res.json();
|
||||
const req = await w(`${this.mutable.BASE_URL}/documents`, { method: 'POST', data: table(data, this.mutable.TABLE_CONFIG) }).send();
|
||||
const res = req.json();
|
||||
|
||||
extData.tags += `\n${this._localize(msg.author.locale.tags.all.extend, { extend: `${this.mutable.BASE_URL}/raw/${res.key}.txt` })}`;
|
||||
}
|
||||
|
||||
msg.channel.createMessage({
|
||||
embed: {
|
||||
color: this.bot.col['tags'],
|
||||
color: this.bot.col.tag.list,
|
||||
description: this._localize(msg.author.locale.tags.all.list.join('\n'), extData)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
if (extData) {
|
||||
if (extData.guild) {
|
||||
msg = msg.replace(/\$\[guild:name]/g, extData.guild);
|
||||
}
|
||||
if (extData.tags) {
|
||||
msg = msg.replace(/\$\[tag:list]/g, extData.tags);
|
||||
}
|
||||
if (extData.extend) {
|
||||
msg = msg.replace(/\$\[tag:full]/g, extData.extend);
|
||||
}
|
||||
if (extData.prefix) {
|
||||
msg = msg.replace(/\$\[tag:cmd]/g, `${extData.prefix}${this.bot.cmds.get('tag-add').extData.syntax}`);
|
||||
}
|
||||
}
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'list', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'list', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'list', '2'));
|
||||
if (extData) {
|
||||
if (extData.guild) {
|
||||
msg = msg.replace(/\$\[guild:name]/g, extData.guild);
|
||||
}
|
||||
if (extData.tags) {
|
||||
msg = msg.replace(/\$\[tag:list]/g, extData.tags);
|
||||
}
|
||||
if (extData.extend) {
|
||||
msg = msg.replace(/\$\[tag:full]/g, extData.extend);
|
||||
}
|
||||
if (extData.prefix) {
|
||||
msg = msg.replace(/\$\[tag:cmd]/g, `${extData.prefix}${this.bot.cmds.get('tag-add').extData.syntax}`);
|
||||
}
|
||||
}
|
||||
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('tags', 'list', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('tags', 'list', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('tags', 'list', '2'));
|
||||
} catch (ex) {
|
||||
return `LOCALIZE_ERROR:${ex}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -53,7 +53,7 @@ module.exports = class Math extends DiscordCommand {
|
||||
}
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = class Snipe extends DiscordCommand {
|
||||
this.bot.cache.delete(`${msg.channel.id}:SNIPE`);
|
||||
}
|
||||
|
||||
_localize(msg, extData) {
|
||||
_localize(msg, extData = {}) {
|
||||
try {
|
||||
if (!msg) throw 'INVALID_STRING';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = class WumpCommand {
|
||||
syntax : null, // Command syntax ( optional )
|
||||
aliases : [], // Command aliases ( optional )
|
||||
argument : [], // Command arguments ( optional )
|
||||
description : null, // Command description ( optional )
|
||||
description: null, // Command description ( optional )
|
||||
// Checks
|
||||
hidden : false, // Hidden from view ( true / false )
|
||||
enabled : true, // Enabled or disabled ( true / false )
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = class name extends DiscordCommand {
|
||||
syntax : '',
|
||||
aliases : [],
|
||||
argument : [],
|
||||
description : '',
|
||||
description: '',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
|
||||
@@ -184,7 +184,7 @@ module.exports = class CommandRegistry {
|
||||
} else return false;
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
|
||||
if (extData.err) msg = msg
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class shardDisconnect extends DiscordEvent {
|
||||
this.bot.hook.send({ content: this.localize(this.strings['connection']['shard']['disconnect'], { shard: id }) });
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
return msg
|
||||
.replace(/\$\[shard:id]/g, extData.shard)
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class ShardReady extends DiscordEvent {
|
||||
this.bot.hook.send({ content: this.localize(this.strings['connection']['shard']['ready'], { shard: id }) });
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
return msg
|
||||
.replace(/\$\[shard:id]/g, extData.shard)
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class ShardResume extends DiscordEvent {
|
||||
this.bot.hook.send({ content: this.localize(this.strings['connection']['shard']['resume'], { shard: id }) });
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
localize(msg, extData = {}) {
|
||||
if (!msg) return '';
|
||||
return msg
|
||||
.replace(/\$\[shard:id]/g, extData.shard)
|
||||
|
||||
Reference in New Issue
Block a user