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