mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Merge Xiao and Fidget
This commit is contained in:
+50
@@ -10,6 +10,8 @@ const client = new CommandoClient({
|
||||
disabledEvents: ['TYPING_START']
|
||||
});
|
||||
const activities = require('./assets/json/activity');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const starred = new Map();
|
||||
|
||||
client.registry
|
||||
.registerDefaultTypes()
|
||||
@@ -26,6 +28,7 @@ client.registry
|
||||
['number-edit', 'Number Manipulation'],
|
||||
['search', 'Search'],
|
||||
['games', 'Games'],
|
||||
['role-manage', 'Role Management'],
|
||||
['other', 'Other'],
|
||||
['roleplay', 'Roleplay']
|
||||
])
|
||||
@@ -56,6 +59,53 @@ client.on('warn', err => console.warn('[WARNING]', err));
|
||||
|
||||
client.on('commandError', (command, err) => console.error('[COMMAND ERROR]', command.name, err));
|
||||
|
||||
client.on('messageReactionAdd', async (reaction, user) => {
|
||||
if (reaction.emoji.name !== '⭐') return;
|
||||
const msg = reaction.message;
|
||||
if (msg.author.id === user.id) {
|
||||
if (msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) await reaction.remove(user);
|
||||
await msg.reply('You cannot star your own messages, idiot.');
|
||||
return;
|
||||
}
|
||||
const starboard = msg.guild.channels.find('name', 'starboard');
|
||||
if (!starboard) return;
|
||||
if (!starboard.permissionsFor(client.user).has(['SEND_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
const embed = new MessageEmbed()
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
|
||||
.setDescription(msg.content)
|
||||
.setImage(msg.attachments.size ? msg.attachments.first().url : null)
|
||||
.setColor(0xFFFF00)
|
||||
.setTimestamp()
|
||||
.setFooter(`⭐ ${reaction.count}`);
|
||||
let starMsg;
|
||||
if (starred.has(msg.id)) starMsg = await starred.get(msg.id).edit(`${reaction.count} ⭐ ${msg.channel}`, { embed });
|
||||
else starMsg = await starboard.send(`${reaction.count} ⭐ ${msg.channel}`, { embed });
|
||||
starred.set(msg.id, starMsg);
|
||||
});
|
||||
|
||||
client.on('messageReactionRemove', async reaction => {
|
||||
if (reaction.emoji.name !== '⭐') return;
|
||||
const msg = reaction.message;
|
||||
if (!starred.has(msg.id)) return;
|
||||
const starboard = msg.guild.channels.find('name', 'starboard');
|
||||
if (!starboard) return;
|
||||
if (!starboard.permissionsFor(client.user).has(['SEND_MESSAGES', 'EMBED_LINKS', 'MANAGE_MESSAGES'])) return;
|
||||
const embed = new MessageEmbed()
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
|
||||
.setDescription(msg.content)
|
||||
.setImage(msg.attachments.size ? msg.attachments.first().url : null)
|
||||
.setColor(0xFFFF00)
|
||||
.setTimestamp()
|
||||
.setFooter(`⭐ ${reaction.count}`);
|
||||
if (reaction.count > 0) {
|
||||
const starMsg = await starred.get(msg.id).edit(`${reaction.count} ⭐ ${msg.channel}`, { embed });
|
||||
starred.set(msg.id, starMsg);
|
||||
} else {
|
||||
await starred.get(msg.id).delete();
|
||||
starred.delete(msg.id);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(XIAO_TOKEN);
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"252317073814978561": [
|
||||
"345655085486964748",
|
||||
"345655164621029379",
|
||||
"345655222888300555"
|
||||
],
|
||||
"346450651326185475": [
|
||||
"346781913358401537",
|
||||
"346782031017017348",
|
||||
"346782170846593028",
|
||||
"346782235304919040"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const roles = require('../../assets/json/roles');
|
||||
|
||||
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.',
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
if (!roles[msg.guild.id]) return msg.say('This server has no roles open...');
|
||||
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')}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const roles = require('../../assets/json/roles');
|
||||
|
||||
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 }) {
|
||||
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 (!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);
|
||||
return msg.say(`You were added to **${role.name}**!`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const roles = require('../../assets/json/roles');
|
||||
|
||||
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 }) {
|
||||
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 (!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);
|
||||
return msg.say(`You were removed from **${role.name}**...`);
|
||||
}
|
||||
};
|
||||
@@ -61,7 +61,7 @@ module.exports = class TwitterCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchToken() {
|
||||
const auth = new Buffer(`${TWITTER_KEY}:${TWITTER_SECRET}`).toString('base64');
|
||||
const auth = Buffer.from(`${TWITTER_KEY}:${TWITTER_SECRET}`).toString('base64');
|
||||
const { body } = await snekfetch
|
||||
.post('https://api.twitter.com/oauth2/token')
|
||||
.set({
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "56.2.0",
|
||||
"version": "56.3.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "XiaoBot.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user