mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add moment to tons of dates
This commit is contained in:
@@ -3,6 +3,7 @@ const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisify } = require('tsubaki');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
const moment = require('moment');
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
|
||||
module.exports = class AnimeCommand extends Command {
|
||||
@@ -52,9 +53,9 @@ module.exports = class AnimeCommand extends Command {
|
||||
.addField('Episodes',
|
||||
anime.entry[0].episodes[0], true)
|
||||
.addField('Start Date',
|
||||
anime.entry[0].start_date[0], true)
|
||||
moment(anime.entry[0].start_date[0]).format('MMMM Do YYYY'), true)
|
||||
.addField('End Date',
|
||||
anime.entry[0].end_date[0], true);
|
||||
moment(anime.entry[0].end_date[0]).format('MMMM Do YYYY'), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('Error: No Results.');
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const moment = require('moment');
|
||||
const { GITHUB_LOGIN } = process.env;
|
||||
|
||||
module.exports = class GithubCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'github',
|
||||
group: 'search',
|
||||
memberName: 'github',
|
||||
description: 'Gets repo information from GitHub.',
|
||||
args: [
|
||||
{
|
||||
key: 'repo',
|
||||
prompt: 'Which repo do you want to get information for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
if (msg.channel.type !== 'dm')
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { repo } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://${GITHUB_LOGIN}@api.github.com/repos/${repo}`);
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFFFFFF)
|
||||
.setAuthor('Github', 'https://i.imgur.com/ajcPgJG.png')
|
||||
.setURL(body.html_url)
|
||||
.setTitle(body.full_name)
|
||||
.setDescription(body.description)
|
||||
.setThumbnail(body.owner.avatar_url)
|
||||
.addField('Creation Date',
|
||||
moment(body.created_at).format('MMMM Do YYYY h:mm:ss A'), true)
|
||||
.addField('Last Updated On',
|
||||
moment(body.created_at).format('MMMM Do YYYY h:mm:ss A'), true)
|
||||
.addField('Stargazers',
|
||||
body.stargazers_count, true)
|
||||
.addField('Watchers',
|
||||
body.watchers_count, true)
|
||||
.addField('Open Issues',
|
||||
body.open_issues_count, true)
|
||||
.addField('Language',
|
||||
body.language, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,6 +3,7 @@ const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisify } = require('tsubaki');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
const moment = require('moment');
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
|
||||
module.exports = class MangaCommand extends Command {
|
||||
@@ -52,9 +53,9 @@ module.exports = class MangaCommand extends Command {
|
||||
.addField('Volumes / Chapters',
|
||||
`${manga.entry[0].volumes[0]} / ${manga.entry[0].chapters[0]}`, true)
|
||||
.addField('Start Date',
|
||||
manga.entry[0].start_date[0], true)
|
||||
moment(anime.entry[0].start_date[0]).format('MMMM Do YYYY'), true)
|
||||
.addField('End Date',
|
||||
manga.entry[0].end_date[0], true);
|
||||
moment(anime.entry[0].end_date[0]).format('MMMM Do YYYY'), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('Error: No Results.');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const moment = require('moment');
|
||||
const { WATTPAD_KEY } = process.env;
|
||||
|
||||
module.exports = class WattpadCommand extends Command {
|
||||
@@ -40,16 +41,17 @@ module.exports = class WattpadCommand extends Command {
|
||||
.setURL(body.stories[0].url)
|
||||
.setTitle(body.stories[0].title)
|
||||
.setDescription(body.stories[0].description.substr(0, 2000))
|
||||
.setThumbnail(body.stories[0].cover)
|
||||
.addField('Author',
|
||||
body.stories[0].user, true)
|
||||
.addField('Created On',
|
||||
moment(body.stories[0].createDate).format('MMMM Do YYYY h:mm:ss A'), true)
|
||||
.addField('Parts',
|
||||
body.stories[0].numParts, true)
|
||||
.addField('Created On',
|
||||
body.stories[0].createDate, true)
|
||||
.addField('Votes',
|
||||
body.stories[0].voteCount, true)
|
||||
.addField('Reads',
|
||||
body.stories[0].readCount, true)
|
||||
.addField('Votes',
|
||||
body.stories[0].voteCount, true)
|
||||
.addField('Comments',
|
||||
body.stories[0].commentCount, true);
|
||||
return msg.embed(embed);
|
||||
|
||||
@@ -29,15 +29,15 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||
if (body.status === 'fail') throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.addField('Card Type',
|
||||
body.data.card_type, true);
|
||||
if (body.data.card_type === 'monster') {
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.addField('Card Type',
|
||||
body.data.card_type, true)
|
||||
.addField('Type',
|
||||
embed.addField('Type',
|
||||
body.data.type, true)
|
||||
.addField('Attribute',
|
||||
body.data.family, true)
|
||||
@@ -47,17 +47,8 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
body.data.def, true)
|
||||
.addField('Level',
|
||||
body.data.level, true);
|
||||
return msg.embed(embed);
|
||||
} else {
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.addField('Card Type',
|
||||
body.data.card_type, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ client.on('commandError', (command, err) => {
|
||||
});
|
||||
|
||||
client.on('message', async (msg) => {
|
||||
if (msg.guild && msg.guild.settings.get('inviteGuard') && /(discord(\.gg\/|app\.com\/invite\/))/gi.test(msg.content)) {
|
||||
if (msg.author.bot
|
||||
|| msg.member.hasPermission('ADMINISTRATOR')
|
||||
|| msg.author.id === msg.guild.ownerID
|
||||
|| msg.member.roles.has(msg.guild.settings.get('staffRole'))
|
||||
|| !msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
if (msg.guild && msg.guild.settings.get('inviteGuard') && /(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) {
|
||||
if (msg.author.bot ||
|
||||
msg.member.hasPermission('ADMINISTRATOR') ||
|
||||
msg.author.id === msg.guild.ownerID ||
|
||||
msg.member.roles.has(msg.guild.settings.get('staffRole')) ||
|
||||
!msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
if (msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) msg.delete();
|
||||
else msg.channel.send('Message could not be deleted, missing the `Manage Messages` permission.');
|
||||
return msg.reply('Invites are prohibited from being posted here.');
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "19.10.4",
|
||||
"version": "19.11.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user