Remove some stuff, fix up role commands

This commit is contained in:
Daniel Odendahl Jr
2017-12-19 01:14:11 +00:00
parent 4216426c22
commit c44ecf0052
11 changed files with 19 additions and 248 deletions
+4 -4
View File
@@ -22,15 +22,15 @@ client.registry
['random', 'Random Response'],
['single', 'Single Response'],
['events', 'Daily Events'],
['search', 'Search'],
['games', 'Games'],
['image-edit', 'Image Manipulation'],
['avatar-edit', 'Avatar Manipulation'],
['text-edit', 'Text Manipulation'],
['number-edit', 'Number Manipulation'],
['search', 'Search'],
['games', 'Games'],
['role-manage', 'Role Management'],
['other', 'Other'],
['roleplay', 'Roleplay']
['roleplay', 'Roleplay'],
['role-manage', 'Home Server Role Management']
])
.registerDefaultCommands({
help: false,
-13
View File
@@ -1,13 +0,0 @@
{
"252317073814978561": [
"345655085486964748",
"345655164621029379",
"345655222888300555"
],
"346450651326185475": [
"346781913358401537",
"346782031017017348",
"346782170846593028",
"346782235304919040"
]
}
+6 -5
View File
@@ -1,24 +1,25 @@
const { Command } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
const roles = require('../../assets/json/roles');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
module.exports = class RolelistCommand extends Command {
module.exports = class RoleListCommand extends Command {
constructor(client) {
super(client, {
name: 'role-list',
aliases: ['roles'],
group: 'role-manage',
memberName: 'role-list',
description: 'Responds with all available roles in this server.',
description: 'Responds with all available roles to join in the home server.',
details: 'This command only works in the home server.',
guildOnly: true
});
}
run(msg) {
if (!roles[msg.guild.id]) return msg.say('This server has no roles open...');
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
return msg.say(stripIndents`
**Roles available in ${msg.guild.name}**:
${msg.guild.roles.filter(role => roles[msg.guild.id].includes(role.id)).map(role => role.name).join('\n')}
${msg.guild.roles.filter(role => HOME_GUILD_ROLES.split(',').includes(role.id)).map(role => role.name).join('\n')}
`);
}
};
+4 -3
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const roles = require('../../assets/json/roles');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
module.exports = class SubscribeCommand extends Command {
constructor(client) {
@@ -9,6 +9,7 @@ module.exports = class SubscribeCommand extends Command {
group: 'role-manage',
memberName: 'subscribe',
description: 'Subscribes you to the specified role.',
details: 'This command only works in the home server.',
guildOnly: true,
clientPermissions: ['MANAGE_ROLES'],
args: [
@@ -22,8 +23,8 @@ module.exports = class SubscribeCommand extends Command {
}
async run(msg, { role }) {
if (!roles[msg.guild.id]) return msg.say('This server has no roles open...');
if (!roles[msg.guild.id].includes(role.id)) return msg.reply('This role is not open!');
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
if (!HOME_GUILD_ROLES.split(',').includes(role.id)) return msg.reply('This role is not open!');
if (!role.editable) return msg.reply('I do not have permission to manage this role!');
if (msg.member.roles.has(role.id)) return msg.reply('You are already a member of this role!');
await msg.member.addRole(role);
+4 -3
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const roles = require('../../assets/json/roles');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
module.exports = class UnsubscribeCommand extends Command {
constructor(client) {
@@ -9,6 +9,7 @@ module.exports = class UnsubscribeCommand extends Command {
group: 'role-manage',
memberName: 'unsubscribe',
description: 'Unsubscribes you from the specified role.',
details: 'This command only works in the home server.',
guildOnly: true,
clientPermissions: ['MANAGE_ROLES'],
args: [
@@ -22,8 +23,8 @@ module.exports = class UnsubscribeCommand extends Command {
}
async run(msg, { role }) {
if (!roles[msg.guild.id]) return msg.say('This server has no roles open...');
if (!roles[msg.guild.id].includes(role.id)) return msg.reply('This role is not open!');
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
if (!HOME_GUILD_ROLES.split(',').includes(role.id)) return msg.reply('This role is not open!');
if (!role.editable) return msg.reply('I do not have permission to manage this role!');
if (!msg.member.roles.has(role.id)) return msg.reply('You are not a member of this role!');
await msg.member.removeRole(role);
-42
View File
@@ -1,42 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class DanbooruCommand extends Command {
constructor(client) {
super(client, {
name: 'danbooru',
aliases: ['danbooru-image'],
group: 'search',
memberName: 'danbooru',
description: 'Responds with an image from Danbooru, with optional query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What image would you like to search for?',
type: 'string',
default: '',
validate: query => {
if (!query.includes(' ')) return true;
return 'Invalid query, please only search for one tag at a time.';
}
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('https://danbooru.donmai.us/posts.json')
.query({
tags: `${query} order:random`,
limit: 1
});
if (!body.length || !body[0].file_url) return msg.say('Could not find any results.');
return msg.say(`https://danbooru.donmai.us${body[0].file_url}`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-37
View File
@@ -1,37 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class DerpibooruCommand extends Command {
constructor(client) {
super(client, {
name: 'derpibooru',
aliases: ['my-little-pony-image', 'mlp-image', 'derpibooru-image'],
group: 'search',
memberName: 'derpibooru',
description: 'Searches Derpibooru for your query.',
args: [
{
key: 'query',
prompt: 'What image would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const search = await snekfetch
.get('https://derpibooru.org/search.json')
.query({
q: query,
random_image: 1
});
if (!search.body) return msg.say('Could not find any results.');
const { body } = await snekfetch.get(`https://derpibooru.org/images/${search.body.id}.json`);
return msg.say(`https:${body.representations.medium}`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-42
View File
@@ -1,42 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class GelbooruCommand extends Command {
constructor(client) {
super(client, {
name: 'gelbooru',
aliases: ['gelbooru-image'],
group: 'search',
memberName: 'gelbooru',
description: 'Responds with an image from Gelbooru, with optional query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What image would you like to search for?',
type: 'string',
default: ''
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('https://gelbooru.com/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
json: 1,
tags: query,
limit: 200
});
if (!body) return msg.say('Could not find any results.');
return msg.say(body[Math.floor(Math.random() * body.length)].file_url);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-60
View File
@@ -1,60 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { IGDB_KEY } = process.env;
const esrb = ['RP', 'EC', 'E', 'E10+', 'T', 'M', 'AO'];
const statuses = ['Released', '???', 'Alpha', 'Beta', 'Early Access', 'Offline', 'Cancelled'];
module.exports = class IGDBCommand extends Command {
constructor(client) {
super(client, {
name: 'igdb',
aliases: ['igdb-video-game', 'game', 'video-game', 'game'],
group: 'search',
memberName: 'igdb',
description: 'Searches IGDB for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What video game would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('https://api-2445582011268.apicast.io/games/')
.query({
search: query,
limit: 1,
fields: '*',
'filter[version_parent][not_exists]': 1
})
.set({ 'user-key': IGDB_KEY });
const data = body[0];
const embed = new MessageEmbed()
.setColor(0x01DF6B)
.setTitle(data.name)
.setURL(data.url)
.setAuthor('IGDB', 'https://i.imgur.com/LHLQEns.png')
.setDescription(data.summary ? shorten(data.summary) : 'No description available.')
.setThumbnail(data.cover ? data.cover.url : null)
.addField(' ESRB Rating',
data.esrb ? esrb[data.esrb.rating - 1] : '???', true)
.addField(' Release Date',
data.first_release_date ? new Date(data.first_release_date).toDateString() : '???', true)
.addField(' Status',
data.status ? statuses[data.status] : '???', true)
.addField(' Score',
data.total_rating || '???', true);
return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-38
View File
@@ -1,38 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class KonachanCommand extends Command {
constructor(client) {
super(client, {
name: 'konachan',
aliases: ['konachan-image'],
group: 'search',
memberName: 'konachan',
description: 'Responds with an image from Konachan, with optional query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What image would you like to search for?',
type: 'string',
default: ''
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('https://konachan.net/post.json')
.query({
tags: `${query} order:random`,
limit: 1
});
if (!body.length || !body[0].file_url) return msg.say('Could not find any results.');
return msg.say(`https:${body[0].file_url}`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "58.4.0",
"version": "59.0.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {