mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 21:44:48 +02:00
Role Management, gelbooru/danbooru/konachan
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class DickCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dick',
|
||||
aliases: ['dick-size'],
|
||||
group: 'random',
|
||||
memberName: 'dick',
|
||||
description: 'Determines your dick size.',
|
||||
nsfw: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say(`8${'='.repeat(Math.floor(Math.random() * 200) + 1)}D`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class AddOpenRoleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'add-open-role',
|
||||
aliases: ['set-open-role', 'open-role'],
|
||||
group: 'role-manage',
|
||||
memberName: 'add-open-role',
|
||||
description: 'Sets a role as open.',
|
||||
guildOnly: true,
|
||||
userPermissions: ['MANAGE_ROLES'],
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'What role do you want to open?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { role }) {
|
||||
if (role.id === msg.guild.defaultRole.id) return msg.reply('The everyone role is already open!');
|
||||
const roles = msg.guild.settings.get('openRoles', []);
|
||||
if (roles.includes(role.id)) return msg.reply(`${role.name} is already open!`);
|
||||
roles.push(role.id);
|
||||
msg.guild.settings.set('openRoles', roles);
|
||||
return msg.say(`${role.name} is now open!`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class FixOpenRolesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fix-open-roles',
|
||||
aliases: ['fix-roles'],
|
||||
group: 'role-manage',
|
||||
memberName: 'fix-open-roles',
|
||||
description: 'Removes no longer existent roles from the open roles lists.',
|
||||
ownerOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
let count = 0;
|
||||
for (const guild of this.client.guilds.values()) {
|
||||
const roles = guild.settings.get('openRoles', []);
|
||||
if (!roles.length) continue;
|
||||
for (const role of roles) {
|
||||
if (guild.roles.has(role)) continue;
|
||||
roles.splice(roles.indexOf(role), 1);
|
||||
count++;
|
||||
}
|
||||
if (!roles.length) guild.settings.remove('openRoles');
|
||||
else guild.settings.set('openRoles', roles);
|
||||
}
|
||||
return msg.say(`Cleared **${count}** roles from the open roles lists.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class RemoveOpenRoleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'remove-open-role',
|
||||
aliases: ['delete-open-role', 'close-role'],
|
||||
group: 'role-manage',
|
||||
memberName: 'remove-open-role',
|
||||
description: 'Remove a role from the open roles.',
|
||||
guildOnly: true,
|
||||
userPermissions: ['MANAGE_ROLES'],
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'What role do you want to close?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { role }) {
|
||||
if (role.id === msg.guild.defaultRole.id) return msg.reply('The everyone role cannot be closed!');
|
||||
const roles = msg.guild.settings.get('openRoles', []);
|
||||
if (!roles.includes(role.id)) return msg.reply(`${role.name} is not open!`);
|
||||
roles.splice(roles.indexOf(role.id), 1);
|
||||
if (!roles.length) msg.guild.settings.remove('openRoles');
|
||||
else msg.guild.settings.set('openRoles', roles);
|
||||
return msg.say(`${role.name} is now closed...`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class RoleListCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'role-list',
|
||||
aliases: ['roles', 'open-roles'],
|
||||
group: 'role-manage',
|
||||
memberName: 'role-list',
|
||||
description: 'Responds with all available roles to join.',
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const roles = msg.guild.settings.get('roles', []);
|
||||
if (!roles.length) return msg.say('This server has no open roles...');
|
||||
return msg.say(stripIndents`
|
||||
**Roles available in ${msg.guild.name}**:
|
||||
${msg.guild.roles.filter(role => roles.includes(role.id)).map(role => role.name).join('\n')}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class SubscribeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'subscribe',
|
||||
aliases: ['join'],
|
||||
group: 'role-manage',
|
||||
memberName: 'subscribe',
|
||||
description: 'Subscribes you to the specified role.',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['MANAGE_ROLES'],
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'What role do you want to subscribe to?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { role }) {
|
||||
const roles = msg.guild.settings.get('openRoles', []);
|
||||
if (!roles.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.roles.add(role);
|
||||
return msg.say(`You were added to **${role.name}**!`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class UnsubscribeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'unsubscribe',
|
||||
aliases: ['leave'],
|
||||
group: 'role-manage',
|
||||
memberName: 'unsubscribe',
|
||||
description: 'Unsubscribes you from the specified role.',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['MANAGE_ROLES'],
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'What role do you want to unsubscribe from?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { role }) {
|
||||
const roles = msg.guild.settings.get('openRoles', []);
|
||||
if (!roles.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.roles.remove(role);
|
||||
return msg.say(`You were removed from **${role.name}**...`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user