mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Remove moment and moment-duration-format
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const moment = require('moment');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { version } = require('../../package');
|
const { version } = require('../../package');
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ module.exports = class CardCommand extends Command {
|
|||||||
ctx.fillStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.fillText(member.displayName, 30, 62);
|
ctx.fillText(member.displayName, 30, 62);
|
||||||
ctx.fillText('Discord Join Date:', 148, 400);
|
ctx.fillText('Discord Join Date:', 148, 400);
|
||||||
ctx.fillText(moment(member.user.createdTimestamp).format('MMMM Do YYYY'), 148, 420);
|
ctx.fillText(member.user.createdAt.toDateString(), 148, 420);
|
||||||
ctx.fillText('Role:', 148, 457);
|
ctx.fillText('Role:', 148, 457);
|
||||||
ctx.fillText(member.highestRole.name !== '@everyone' ? member.highestRole.name : 'None', 148, 477);
|
ctx.fillText(member.highestRole.name !== '@everyone' ? member.highestRole.name : 'None', 148, 477);
|
||||||
ctx.fillText(rarity, 73, 411);
|
ctx.fillText(rarity, 73, 411);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const moment = require('moment');
|
|
||||||
|
|
||||||
module.exports = class ChannelInfoCommand extends Command {
|
module.exports = class ChannelInfoCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -34,7 +33,7 @@ module.exports = class ChannelInfoCommand extends Command {
|
|||||||
.addField('❯ NSFW',
|
.addField('❯ NSFW',
|
||||||
channel.nsfw ? 'Yes' : 'No', true)
|
channel.nsfw ? 'Yes' : 'No', true)
|
||||||
.addField('❯ Creation Date',
|
.addField('❯ Creation Date',
|
||||||
moment(channel.createdAt).format('MMMM Do YYYY'), true)
|
channel.createdAt.toDateString(), true)
|
||||||
.addField('❯ Topic',
|
.addField('❯ Topic',
|
||||||
channel.topic || 'None');
|
channel.topic || 'None');
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const moment = require('moment');
|
|
||||||
const perms = require('../../assets/json/permissions');
|
const perms = require('../../assets/json/permissions');
|
||||||
|
|
||||||
module.exports = class RoleInfoCommand extends Command {
|
module.exports = class RoleInfoCommand extends Command {
|
||||||
@@ -34,7 +33,7 @@ module.exports = class RoleInfoCommand extends Command {
|
|||||||
.addField('❯ Color',
|
.addField('❯ Color',
|
||||||
role.hexColor.toUpperCase(), true)
|
role.hexColor.toUpperCase(), true)
|
||||||
.addField('❯ Creation Date',
|
.addField('❯ Creation Date',
|
||||||
moment(role.createdAt).format('MMMM Do YYYY'), true)
|
role.createdAt.toDateString(), true)
|
||||||
.addField('❯ Hoisted',
|
.addField('❯ Hoisted',
|
||||||
role.hoist ? 'Yes' : 'No', true)
|
role.hoist ? 'Yes' : 'No', true)
|
||||||
.addField('❯ Mentionable',
|
.addField('❯ Mentionable',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const moment = require('moment');
|
|
||||||
const filterLevels = ['Off', 'No Role', 'Everyone'];
|
const filterLevels = ['Off', 'No Role', 'Everyone'];
|
||||||
const verificationLevels = ['None', 'Low', 'Medium', '(╯°□°)╯︵ ┻━┻', '┻━┻ ミヽ(ಠ益ಠ)ノ彡┻━┻'];
|
const verificationLevels = ['None', 'Low', 'Medium', '(╯°□°)╯︵ ┻━┻', '┻━┻ ミヽ(ಠ益ಠ)ノ彡┻━┻'];
|
||||||
|
|
||||||
@@ -26,7 +25,7 @@ module.exports = class GuildInfoCommand extends Command {
|
|||||||
.addField('❯ ID',
|
.addField('❯ ID',
|
||||||
msg.guild.id, true)
|
msg.guild.id, true)
|
||||||
.addField('❯ Creation Date',
|
.addField('❯ Creation Date',
|
||||||
moment(msg.guild.createdAt).format('MMMM Do YYYY'), true)
|
msg.guild.createdAt.toDateString(), true)
|
||||||
.addField('❯ Region',
|
.addField('❯ Region',
|
||||||
msg.guild.region, true)
|
msg.guild.region, true)
|
||||||
.addField('❯ Explicit Filter',
|
.addField('❯ Explicit Filter',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const moment = require('moment');
|
|
||||||
const { GITHUB_LOGIN } = process.env;
|
const { GITHUB_LOGIN } = process.env;
|
||||||
|
|
||||||
module.exports = class GitHubCommand extends Command {
|
module.exports = class GitHubCommand extends Command {
|
||||||
@@ -48,9 +47,9 @@ module.exports = class GitHubCommand extends Command {
|
|||||||
.addField('❯ Language',
|
.addField('❯ Language',
|
||||||
body.language || 'N/A', true)
|
body.language || 'N/A', true)
|
||||||
.addField('❯ Created',
|
.addField('❯ Created',
|
||||||
moment(body.created_at).format('MMMM Do YYYY'), true)
|
new Date(body.created_at).toDateString(), true)
|
||||||
.addField('❯ Modified',
|
.addField('❯ Modified',
|
||||||
moment(body.updated_at).format('MMMM Do YYYY'), true);
|
new Date(body.updated_at).toDateString(), true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 404) return msg.say('Could not find any results.');
|
if (err.status === 404) return msg.say('Could not find any results.');
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const moment = require('moment');
|
|
||||||
const { shorten } = require('../../structures/Util');
|
const { shorten } = require('../../structures/Util');
|
||||||
|
|
||||||
module.exports = class NPMCommand extends Command {
|
module.exports = class NPMCommand extends Command {
|
||||||
@@ -16,7 +15,8 @@ module.exports = class NPMCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'query',
|
key: 'query',
|
||||||
prompt: 'What package would you like to search for?',
|
prompt: 'What package would you like to search for?',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
parse: query => encodeURIComponent(query)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -40,9 +40,9 @@ module.exports = class NPMCommand extends Command {
|
|||||||
.addField('❯ Author',
|
.addField('❯ Author',
|
||||||
body.author ? body.author.name : 'Unknown', true)
|
body.author ? body.author.name : 'Unknown', true)
|
||||||
.addField('❯ Created',
|
.addField('❯ Created',
|
||||||
moment(body.time.created).format('MMMM Do YYYY'), true)
|
new Date(body.time.created).toDateString(), true)
|
||||||
.addField('❯ Modified',
|
.addField('❯ Modified',
|
||||||
moment(body.time.modified).format('MMMM Do YYYY'), true)
|
new Date(body.time.modified).toDateString(), true)
|
||||||
.addField('❯ Main File',
|
.addField('❯ Main File',
|
||||||
body.versions[body['dist-tags'].latest].main, true)
|
body.versions[body['dist-tags'].latest].main, true)
|
||||||
.addField('❯ Keywords',
|
.addField('❯ Keywords',
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const moment = require('moment');
|
const { shorten, duration } = require('../../structures/Util');
|
||||||
const { shorten } = require('../../structures/Util');
|
|
||||||
|
|
||||||
module.exports = class VocaloidCommand extends Command {
|
module.exports = class VocaloidCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -37,6 +36,7 @@ module.exports = class VocaloidCommand extends Command {
|
|||||||
fields: 'ThumbUrl,Lyrics'
|
fields: 'ThumbUrl,Lyrics'
|
||||||
});
|
});
|
||||||
if (!body.totalCount) return msg.say('Could not find any results.');
|
if (!body.totalCount) return msg.say('Could not find any results.');
|
||||||
|
const { minutes, seconds } = duration(body.items[0].lengthSeconds * 1000);
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0x86D2D0)
|
.setColor(0x86D2D0)
|
||||||
.setAuthor('VocaDB', 'https://i.imgur.com/9Tx9UIc.jpg')
|
.setAuthor('VocaDB', 'https://i.imgur.com/9Tx9UIc.jpg')
|
||||||
@@ -47,9 +47,9 @@ module.exports = class VocaloidCommand extends Command {
|
|||||||
.addField('❯ Artist',
|
.addField('❯ Artist',
|
||||||
body.items[0].artistString)
|
body.items[0].artistString)
|
||||||
.addField('❯ Publish Date',
|
.addField('❯ Publish Date',
|
||||||
moment(body.items[0].publishDate).format('MMMM Do YYYY'), true)
|
new Date(body.items[0].publishDate).toDateString(), true)
|
||||||
.addField('❯ Length',
|
.addField('❯ Length',
|
||||||
moment.duration(body.items[0].lengthSeconds, 's').format(), true);
|
`${minutes}:${seconds}`, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const moment = require('moment');
|
|
||||||
const { shorten } = require('../../structures/Util');
|
const { shorten } = require('../../structures/Util');
|
||||||
const { WATTPAD_KEY } = process.env;
|
const { WATTPAD_KEY } = process.env;
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ module.exports = class WattpadCommand extends Command {
|
|||||||
.setDescription(shorten(body.stories[0].description))
|
.setDescription(shorten(body.stories[0].description))
|
||||||
.setThumbnail(body.stories[0].cover)
|
.setThumbnail(body.stories[0].cover)
|
||||||
.addField('❯ Created On',
|
.addField('❯ Created On',
|
||||||
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
|
new Date(body.stories[0].createDate).toDateString(), true)
|
||||||
.addField('❯ Author',
|
.addField('❯ Author',
|
||||||
body.stories[0].user, true)
|
body.stories[0].user, true)
|
||||||
.addField('❯ Parts',
|
.addField('❯ Parts',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const moment = require('moment');
|
|
||||||
const statuses = {
|
const statuses = {
|
||||||
online: '<:online:313956277808005120> Online',
|
online: '<:online:313956277808005120> Online',
|
||||||
idle: '<:away:313956277220802560> Idle',
|
idle: '<:away:313956277220802560> Idle',
|
||||||
@@ -39,9 +38,9 @@ module.exports = class UserInfoCommand extends Command {
|
|||||||
.addField('❯ ID',
|
.addField('❯ ID',
|
||||||
member.id, true)
|
member.id, true)
|
||||||
.addField('❯ Discord Join Date',
|
.addField('❯ Discord Join Date',
|
||||||
moment(member.user.createdAt).format('MMMM Do YYYY'), true)
|
member.user.createdAt.toDateString(), true)
|
||||||
.addField('❯ Server Join Date',
|
.addField('❯ Server Join Date',
|
||||||
moment(member.joinedTimestamp).format('MMMM Do YYYY'), true)
|
member.joinedAt.toDateString(), true)
|
||||||
.addField('❯ Status',
|
.addField('❯ Status',
|
||||||
statuses[member.presence.status], true)
|
statuses[member.presence.status], true)
|
||||||
.addField('❯ Playing',
|
.addField('❯ Playing',
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { version } = require('../../package');
|
const { version } = require('../../package');
|
||||||
const moment = require('moment');
|
const { duration } = require('../../structures/Util');
|
||||||
require('moment-duration-format');
|
|
||||||
|
|
||||||
module.exports = class InfoCommand extends Command {
|
module.exports = class InfoCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -34,7 +33,7 @@ module.exports = class InfoCommand extends Command {
|
|||||||
.addField('❯ Memory Usage',
|
.addField('❯ Memory Usage',
|
||||||
`${Math.round(memory.reduce((prev, val) => prev + val, 0) / 1024 / 1024)}MB`, true)
|
`${Math.round(memory.reduce((prev, val) => prev + val, 0) / 1024 / 1024)}MB`, true)
|
||||||
.addField('❯ Uptime',
|
.addField('❯ Uptime',
|
||||||
moment.duration(this.client.uptime).format('d[d]h[h]m[m]s[s]'), true)
|
duration(this.client.uptime).format, true)
|
||||||
.addField('❯ Version',
|
.addField('❯ Version',
|
||||||
`v${version}`, true)
|
`v${version}`, true)
|
||||||
.addField('❯ Node Version',
|
.addField('❯ Node Version',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const moment = require('moment');
|
const { duration } = require('../../structures/Util');
|
||||||
require('moment-duration-format');
|
|
||||||
|
|
||||||
module.exports = class ShardInfoCommand extends Command {
|
module.exports = class ShardInfoCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -40,7 +39,7 @@ module.exports = class ShardInfoCommand extends Command {
|
|||||||
.addField('❯ Memory Usage',
|
.addField('❯ Memory Usage',
|
||||||
`${Math.round(memory[shard] / 1024 / 1024)}MB`, true)
|
`${Math.round(memory[shard] / 1024 / 1024)}MB`, true)
|
||||||
.addField('❯ Uptime',
|
.addField('❯ Uptime',
|
||||||
moment.duration(uptime[shard]).format('d[d]h[h]m[m]s[s]'), true);
|
duration(uptime[shard]).format, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const moment = require('moment');
|
const { duration } = require('../../structures/Util');
|
||||||
require('moment-duration-format');
|
|
||||||
|
|
||||||
module.exports = class UptimeCommand extends Command {
|
module.exports = class UptimeCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -14,6 +13,6 @@ module.exports = class UptimeCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run(msg) {
|
run(msg) {
|
||||||
return msg.say(moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]'));
|
return msg.say(duration(this.client.uptime).format);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "34.0.1",
|
"version": "34.0.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -36,8 +36,6 @@
|
|||||||
"discord.js": "github:hydrabolt/discord.js",
|
"discord.js": "github:hydrabolt/discord.js",
|
||||||
"discord.js-commando": "github:gawdl3y/discord.js-commando",
|
"discord.js-commando": "github:gawdl3y/discord.js-commando",
|
||||||
"erlpack": "github:hammerandchisel/erlpack",
|
"erlpack": "github:hammerandchisel/erlpack",
|
||||||
"moment": "^2.18.1",
|
|
||||||
"moment-duration-format": "^1.3.0",
|
|
||||||
"node-opus": "^0.2.6",
|
"node-opus": "^0.2.6",
|
||||||
"snekfetch": "^3.2.9",
|
"snekfetch": "^3.2.9",
|
||||||
"uws": "^8.14.1",
|
"uws": "^8.14.1",
|
||||||
|
|||||||
@@ -73,6 +73,18 @@ class Util {
|
|||||||
const filtered = arr.filter(entry => entry.language.name === 'en');
|
const filtered = arr.filter(entry => entry.language.name === 'en');
|
||||||
return filtered[Math.floor(Math.random() * filtered.length)];
|
return filtered[Math.floor(Math.random() * filtered.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static duration(ms) {
|
||||||
|
const sec = Math.floor((ms / 1000) % 60);
|
||||||
|
const min = Math.floor((ms / (1000 * 60)) % 60);
|
||||||
|
const hrs = Math.floor(ms / (1000 * 60 * 60));
|
||||||
|
return {
|
||||||
|
hours: hrs,
|
||||||
|
minutes: min,
|
||||||
|
seconds: sec,
|
||||||
|
format: `${hrs < 10 ? `0${hrs}` : hrs}:${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Util;
|
module.exports = Util;
|
||||||
|
|||||||
Reference in New Issue
Block a user