mirror of
https://github.com/Wessel/yorushika.git
synced 2026-07-20 23:45:05 +02:00
Add commits cmd and hopefully fix the double db issue!
This commit is contained in:
@@ -15,6 +15,7 @@ util :
|
||||
info :
|
||||
stats : 0x02C2F33 # Dark but not black
|
||||
guild : 0x7289DA # Blurple
|
||||
commits : 0x7289DA # Blurple
|
||||
avatar : 0x02C2F33 # Dark but not black
|
||||
commands: 0x02C2F33 # Dark but not black
|
||||
|
||||
|
||||
@@ -51,7 +51,10 @@ info:
|
||||
13 : <:dnd:362670805676720128> # Total DnD members
|
||||
14 : <:offline:362670805441708032> # Total offline members
|
||||
15 : <:exclamation:542368036255039509> # Invalid query
|
||||
avatar : <:blueberry:506201160382939141> # User's avatar
|
||||
avatar : <:blueberry:506201160382939141> # User's avatar
|
||||
commits :
|
||||
0 : <:wumplus:542809926414761995> # 10 most recent commits
|
||||
1 : <:early:542366345795207178> # Total commits
|
||||
commands :
|
||||
0 : <:blueberry:506201160382939141> # Guild prefix
|
||||
1 : <:spirit:332131321759399937> # More info
|
||||
|
||||
@@ -5,12 +5,10 @@ translation :
|
||||
orig : 'English (United States)' # Full language name in your language
|
||||
progress : 100 # Progression of the translation (%)
|
||||
translator : # Your information (can leave fields empty)
|
||||
email : 'discord@go2it.eu' # Optional
|
||||
website : 'https://wessel.meek.moe' # Optional
|
||||
discord :
|
||||
name : 'Wesselgame' # Required, can be set to "Clyde"
|
||||
userid : '107130754189766656' # Required, can be set to "1"
|
||||
discrim: '0498' # Required, can be set to "0001"
|
||||
- name : 'Wesselgame' # Required, can be set to "Clyde"
|
||||
userid : '107130754189766656' # Required, can be set to "1"
|
||||
discrim: '0498' # Required, can be set to "0001"
|
||||
|
||||
error :
|
||||
- '$[author:mention] **>** An error occurred while executing this command'
|
||||
@@ -63,6 +61,9 @@ info :
|
||||
stats :
|
||||
fetching: '$[emoji#0] Fetching statistics, this may take some time...'
|
||||
avatar : '$[emoji#0] Here''s **$[user:full]** avatar'
|
||||
commits :
|
||||
- '$[emoji#1] **Total commits**: [`$[commits:total]`](https://github.com/PassTheWessel/wump/commits "Click here for a list of all commits")'
|
||||
- '$[emoji#0] **10 most recent commits done on [`PassTheWessel/wump`](https://github.com/PassTheWessel/wump/)**: $[commits:list]'
|
||||
commands:
|
||||
multi :
|
||||
- '$[emoji#0] The prefix for **$[guild:name]** is `$[guild:prefix]`'
|
||||
|
||||
@@ -5,10 +5,8 @@ translation :
|
||||
orig : 'Nederlands' # Full language name in your language
|
||||
progress : 100 # Progression of the translation (%)
|
||||
translator : # Your information (can leave fields empty)
|
||||
email : 'discord@go2it.eu' # Optional
|
||||
website : 'https://wessel.meek.moe' # Optional
|
||||
discord :
|
||||
name : 'Wesselgame' # Required, can be set to "Clyde"
|
||||
- name : 'Wesselgame' # Required, can be set to "Clyde"
|
||||
userid : '107130754189766656' # Required, can be set to "1"
|
||||
discrim: '0498' # Required, can be set to "0001"
|
||||
|
||||
|
||||
BIN
src/assets/img/emoji/wumplus.png
Normal file
BIN
src/assets/img/emoji/wumplus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -22,6 +22,9 @@ module.exports = class Locale extends DiscordCommand {
|
||||
}
|
||||
|
||||
async execute(msg, args, user, guild) {
|
||||
if (!user || user === null) user = await this.bot.m.connection.collection('dUsers').findOne({ userId: msg.author.id });
|
||||
if (!guild || guild === null) guild = await this.bot.m.connection.collection('dGuilds').findOne({ guildId: msg.channel.guild.id });
|
||||
|
||||
if (args.join(' ').includes('-u') || args.join(' ').includes('--user')) {
|
||||
for (let i = 0; i < args.length; i++) !this.bot.locales.has(args[i]) ? args.splice(i, -1) : undefined;
|
||||
if (!this.bot.locales.has(args[0])) return msg.channel.createMessage(this.localize(msg.author.locale['core']['locale']['invalid']));
|
||||
|
||||
@@ -25,8 +25,9 @@ module.exports = class Eval extends DiscordCommand {
|
||||
}
|
||||
|
||||
localize(msg) {
|
||||
// Empty
|
||||
if (!msg) return '';
|
||||
|
||||
// Main
|
||||
return msg.replace(/\$\[emoji#0]/g, this.bot.emote('developer', 'echo'));
|
||||
}
|
||||
};
|
||||
@@ -5,12 +5,13 @@ const { inspect } = require('util');
|
||||
module.exports = class Eval extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
// Information
|
||||
name : 'eval',
|
||||
syntax : 'eval <...code:str>',
|
||||
aliases : [],
|
||||
argument : [],
|
||||
description: 'Evaluate a snippet',
|
||||
|
||||
// Checks
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 0,
|
||||
@@ -23,13 +24,12 @@ module.exports = class Eval extends DiscordCommand {
|
||||
|
||||
async execute(msg, args) {
|
||||
let result;
|
||||
let silent = args.join(' ').trim().endsWith('--silent') || args.join(' ').trim().endsWith('-s');
|
||||
let silent = args.join(' ').trim().endsWith('--silent') || args.join(' ').trim().endsWith('-s') ? args.pop() : false;
|
||||
let asynchr = args.join(' ').trim().includes('return') || args.join(' ').trim().includes('await');
|
||||
let errored = false;
|
||||
|
||||
if (args.length <= 0) return msg.channel.createMessage(this.localize(msg.author.locale['developer']['eval']['args']));
|
||||
|
||||
if (silent) args = args.pop();
|
||||
const message = await msg.channel.createMessage(this.localize(msg.author.locale['developer']['eval']['busy']));
|
||||
|
||||
try { result = (asynchr ? eval(`(async() => {${args.join(' ')}})();`) : eval(args.join(' '))); }
|
||||
@@ -41,29 +41,37 @@ module.exports = class Eval extends DiscordCommand {
|
||||
message.edit({
|
||||
content: '',
|
||||
embed: {
|
||||
color : errored ? this.bot.col['developer']['eval']['failure'] : this.bot.col['developer']['eval']['success'],
|
||||
description: this.localize(msg.author.locale['developer']['eval']['result'].join('\n'), { resultType: errored ? msg.author.locale['developer']['eval']['types'][1] : msg.author.locale['developer']['eval']['types'][0], resultMessage: this.bot.util.shorten(result, 1950) || '{}' })
|
||||
color : (errored ? this.bot.col['developer']['eval']['failure'] : this.bot.col['developer']['eval']['success']),
|
||||
description: this.localize(msg.author.locale['developer']['eval']['result'].join('\n'), { resultType: errored ? msg.author.locale['developer']['eval']['types'][1] : msg.author.locale['developer']['eval']['types'][0], resultMessage: this.bot.util.shorten(result, 1900) || '{}' })
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
sanitize(msg) {
|
||||
// Empty
|
||||
if (!msg) return undefined;
|
||||
|
||||
for(let _ in this.bot.conf['api']) msg = msg.replace(new RegExp(this.bot.conf['api'][_], 'gi'), '<--snip-->');
|
||||
|
||||
// API tokens
|
||||
for(let _ in this.bot.conf['api']) {
|
||||
msg = msg.replace(new RegExp(this.bot.conf['api'][_], 'gi'), '<--snip-->');
|
||||
}
|
||||
// Bot tokens
|
||||
return msg
|
||||
.replace(new RegExp(this.bot.token, 'gi'), '<--snip-->')
|
||||
.replace(new RegExp(this.bot.conf['discord']['token'], 'gi'), '<--snip-->');
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
// Empty
|
||||
if (!msg) return '';
|
||||
|
||||
if (extData && extData.resultType) msg = msg.replace(/\$\[result:type]/g, extData.resultType);
|
||||
if (extData && extData.resultMessage) msg = msg.replace(/\$\[result:message]/g, extData.resultMessage);
|
||||
|
||||
// extData
|
||||
if (extData && extData.resultType) {
|
||||
msg = msg.replace(/\$\[result:type]/g, extData.resultType);
|
||||
}
|
||||
if (extData && extData.resultMessage) {
|
||||
msg = msg.replace(/\$\[result:message]/g, extData.resultMessage);
|
||||
}
|
||||
// Main
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('developer', 'eval', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('developer', 'eval', '1'))
|
||||
|
||||
@@ -43,11 +43,6 @@ module.exports = class Commands extends DiscordCommand {
|
||||
thumbnail : { url: 'attachment://thumb.png' },
|
||||
description: this.localize(msg.author.locale['info']['commands']['multi'].join('\n'), { msg: msg }),
|
||||
fields : [
|
||||
{
|
||||
name : msg.author.locale['info']['commands']['fields'][0],
|
||||
value : this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'),
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name : msg.author.locale['info']['commands']['fields'][1],
|
||||
value : this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'information' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'),
|
||||
@@ -67,6 +62,11 @@ module.exports = class Commands extends DiscordCommand {
|
||||
name : msg.author.locale['info']['commands']['fields'][4],
|
||||
value : this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'developer' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'),
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name : msg.author.locale['info']['commands']['fields'][0],
|
||||
value : this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'),
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
44
src/commands/Discord/Information/commits.js
Normal file
44
src/commands/Discord/Information/commits.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const { DiscordCommand } = require('../../../core');
|
||||
|
||||
const w = require('wumpfetch');
|
||||
module.exports = class Stats extends DiscordCommand {
|
||||
constructor(bot) {
|
||||
super(bot, {
|
||||
name : 'commits',
|
||||
syntax : 'commits',
|
||||
aliases : [],
|
||||
argument : [],
|
||||
description: '10 most recent commits',
|
||||
|
||||
hidden : false,
|
||||
enabled : true,
|
||||
cooldown : 5000,
|
||||
category : 'Information',
|
||||
ownerOnly : false,
|
||||
guildOnly : false,
|
||||
permissions: [ 'embedLinks' ]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async execute( msg, args ) {
|
||||
let res = await w('https://api.github.com/repos/PassTheWessel/wump/commits', { headers: { 'User-Agent': this.bot.ua } }).send();
|
||||
res = res.json();
|
||||
|
||||
msg.channel.createMessage({
|
||||
embed: {
|
||||
color : this.bot.col['info']['commits'],
|
||||
description: this.localize(msg.author.locale['info']['commits'].join('\n'), { total: res.length, commits: res.map((v) => `**•** [\`${v.sha.slice(0, 7)}\`](${v.html_url}) **⤏** ${this.bot.util.shorten(v.commit.message, 80)}`).slice(0, 10).join('\n') })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
localize(msg, extData) {
|
||||
if (!msg) return '';
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('info', 'commits', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('info', 'commits', '1'))
|
||||
.replace(/\$\[commits:list]/g, `\n${extData.commits}`)
|
||||
.replace(/\$\[commits:total]/g, `\n${extData.total}`);
|
||||
}
|
||||
};
|
||||
@@ -2,12 +2,13 @@ module.exports = class WumpCommand {
|
||||
constructor(bot, opts = {}) {
|
||||
this.bot = bot;
|
||||
this.extData = Object.assign({
|
||||
// Information
|
||||
name : null, // Command name ( required )
|
||||
syntax : null, // Command syntax ( optional )
|
||||
aliases : [], // Command aliases ( optional )
|
||||
argument : [], // Command arguments ( optional )
|
||||
description : null, // Command description ( optional )
|
||||
|
||||
// Checks
|
||||
hidden : false, // Hidden from view ( true / false )
|
||||
enabled : true, // Enabled or disabled ( true / false )
|
||||
cooldown : 1000, // Command cooldown ( optional )
|
||||
|
||||
@@ -68,23 +68,34 @@ module.exports = class CommandRegistry {
|
||||
perm = msg.channel.permissionsOf(this.bot.user.id);
|
||||
gCache = this.bot.cache.has('guilds') ? this.bot.cache.get('guilds') : this.bot.cache.set('guilds', []) && this.bot.cache.get('guilds');
|
||||
uCache = this.bot.cache.has('users') ? this.bot.cache.get('users') : this.bot.cache.set('users', []) && this.bot.cache.get('users');
|
||||
|
||||
if (!this.checkArray('guildId', msg.channel.guild.id, gCache)) {
|
||||
guild = await this.bot.m.connection.collection('dGuilds').findOne({ guildId: msg.channel.guild.id });
|
||||
if (guild === null || !guild) {
|
||||
guild = new this.bot.schema.guild({ guildId: msg.channel.guild.id });
|
||||
await guild.save((err) => { if (err) process.handleError(err); });
|
||||
} else gCache.push({ 'guildId': msg.channel.guild.id, 'prefix': guild.prefix, 'entryAge': Date.now() });
|
||||
} else guild = gCache.filter((v) => v['guildId'] === msg.channel.guild.id );
|
||||
// guild = await this.bot.m.connection.collection('dGuilds').findOne({ guildId: msg.channel.guild.id });
|
||||
this.bot.m.connection.collection('dGuilds').findOne({ guildId: msg.channel.guild.id }, async (err, doc) => {
|
||||
if (doc === null) {
|
||||
guild = new this.bot.schema.guild({ guildId: msg.channel.guild.id });
|
||||
guild.save((err) => { if (err) process.handleError(err); });
|
||||
gCache.push({ 'guildId': msg.channel.guild.id, 'prefix': guild.prefix, 'entryAge': Date.now() });
|
||||
} else {
|
||||
guild = await this.bot.m.connection.collection('dGuilds').findOne({ guildId: msg.channel.guild.id });
|
||||
gCache.push({ 'guildId': msg.channel.guild.id, 'prefix': guild.prefix, 'entryAge': Date.now() });
|
||||
}
|
||||
});
|
||||
} else guild = gCache.filter((v) => v['guildId'] === msg.channel.guild.id )[0];
|
||||
|
||||
if (!this.checkArray('userId', msg.author.id, uCache)) {
|
||||
user = await this.bot.m.connection.collection('dUsers').findOne({ userId: msg.author.id });
|
||||
if (user === null || !user) {
|
||||
user = new this.bot.schema.user({ userId: msg.author.id });
|
||||
await user.save((err) => { if (err) process.handleError(err); });
|
||||
} else uCache.push({ 'userId': msg.author.id, locale: user.locale ? user.locale : this.bot.conf['discord']['locale'], 'entryAge': Date.now() });
|
||||
this.bot.m.connection.collection('dUsers').findOne({ userId: msg.author.id }, async (err, doc) => {
|
||||
if (doc === null) {
|
||||
user = new this.bot.schema.user({ userId: msg.author.id });
|
||||
user.save((err) => { if (err) process.handleError(err); });
|
||||
uCache.push({ 'userId': msg.author.id, locale: user.locale ? user.locale : this.bot.conf['discord']['locale'], 'prefix': user.prefix, 'entryAge': Date.now() });
|
||||
} else {
|
||||
user = await this.bot.m.connection.collection('dUsers').findOne({ userId: msg.author.id });
|
||||
uCache.push({ 'userId': msg.author.id, locale: user.locale ? user.locale : this.bot.conf['discord']['locale'], 'entryAge': Date.now() });
|
||||
}
|
||||
});
|
||||
} else user = uCache.filter((v) => v['userId'] === msg.author.id )[0];
|
||||
msg.author.locale = this.bot.locales.get(user['locale'] ? user['locale'] : 'en_us');
|
||||
|
||||
msg.author.locale = this.bot.locales.get(user && user['locale'] ? user['locale'] : 'en_us');
|
||||
prefix = new RegExp([
|
||||
`^<@!?${this.bot.user.id}> `,
|
||||
`^${this.bot.conf['discord']['prefix'].replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')}`,
|
||||
@@ -108,8 +119,8 @@ module.exports = class CommandRegistry {
|
||||
if (!this.bot.cache.has('commands_ran')) this.bot.cache.set('commands_ran', 1);
|
||||
else this.bot.cache.set('commands_ran', this.bot.cache.get('commands_ran') + 1);
|
||||
|
||||
user['entryAge'] = Date.now();
|
||||
guild['entryAge'] = Date.now();
|
||||
user ? user['entryAge'] = Date.now() : undefined;
|
||||
guild ? guild['entryAge'] = Date.now() : undefined;
|
||||
cmd = cmd[0];
|
||||
|
||||
if (cmd.extData.ownerOnly && !this.bot.op(msg.author.id))
|
||||
|
||||
Reference in New Issue
Block a user