first on gitea
This commit is contained in:
1 parent
27894dac21
commit
94bf054772
6 files changed
+2628
-2456
No files matched your search
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"autoroles": {
|
||||
"1133441692196950101": "1192595134026616894"
|
||||
},
|
||||
"autobans": {
|
||||
"1133441692196950101": "1264634623950848158"
|
||||
}
|
||||
}
|
||||
+2467
-2454
File diff suppressed because it is too large.
Load diff
@@ -47,7 +47,7 @@ module.exports = {
|
||||
name: 'rbx',
|
||||
description: `various commands related to roblox`,
|
||||
aliases: ['roblox'],
|
||||
usage: 'rbx user <username>\n.rbx item <item id>\n.rbx group <group id>\n.rbx game <game id>',
|
||||
usage: 'rbx user <username>\n.rbx item <item id>\n.rbx group <group id>\n.rbx game <game id>\n.rbx avatar <username>',
|
||||
|
||||
async execute(client, message) {
|
||||
var embed = {};
|
||||
@@ -208,6 +208,43 @@ module.exports = {
|
||||
timestamp: new Date(),
|
||||
}
|
||||
}
|
||||
} else if (subcommand === 'avatar') {
|
||||
try {
|
||||
const res = await fetch(`https://thumbnails.roproxy.com/v1/users/avatar?userIds=${id}&size=420x420&format=Png&isCircular=false`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `${}`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch avatar for user id "${argument}":`, err);
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> could not fetch avatar data for user "${argument}"!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
}
|
||||
} else if (subcommand === 'item') {
|
||||
try {
|
||||
const res = await fetch(`https://economy.roproxy.com/v2/assets/${argument}/details`, {
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'autoban',
|
||||
description: `automatically ban a user if they join the server`,
|
||||
aliases: ['ab', 'banish'],
|
||||
usage: 'ban <user> [reason] [duration]',
|
||||
|
||||
async execute(client, message, args) {
|
||||
if (!message.member.permissions.has('BanMembers')) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> you do not have permission to use this command!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const user = message.mentions.users.first() || await client.users.fetch(args[0]).catch(() => null);
|
||||
if (!user) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> please specify a user to autoban!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const reason = args.slice(1).join(' ') || 'autobanned (twitter)';
|
||||
|
||||
const dbPath = path.join(__dirname, '..', '..', '..', 'db.json');
|
||||
|
||||
let db = {};
|
||||
if (fs.existsSync(dbPath)) {
|
||||
db = JSON.parse(fs.readFileSync(dbPath, 'utf8'));
|
||||
}
|
||||
|
||||
if (!db.autobans) {
|
||||
db.autobans = {};
|
||||
}
|
||||
|
||||
db.autobans[message.guild.id] = user.id;
|
||||
|
||||
try {
|
||||
await fs.writeFileSync(dbPath, JSON.stringify(db, null, 2));
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:check:1481811973447356496> ${user.username} has been added to the autoban list!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> an error occurred while trying to add the user to the autoban list!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -5,7 +5,7 @@ const { time } = require("discord.js");
|
||||
module.exports = {
|
||||
name: 'ban',
|
||||
description: `ban a user from the current server`,
|
||||
aliases: ['banish'],
|
||||
aliases: ['b'],
|
||||
usage: 'ban <user> [reason] [duration]',
|
||||
|
||||
async execute(client, message, args) {
|
||||
|
||||
@@ -30,4 +30,21 @@ module.exports = (client, member) => {
|
||||
.then(() => logger.info(`assigned role "${role.name}" to user "${member.user.tag}"!`))
|
||||
.catch(error => logger.error(`failed to assign role "${role.name}" to user "${member.user.tag}": ${error}`));
|
||||
}
|
||||
|
||||
// autoban
|
||||
{
|
||||
const autoban = db.autobans ? db.autobans[member.guild.id] : null;
|
||||
if (!autoban) {
|
||||
logger.info(`no autoban is set up for ${member.user.tag} in "${member.guild.name}"`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.user.tag === autoban) {
|
||||
member.ban({ reason: 'autobanned (twitter)' })
|
||||
.then(() => logger.info(`autobanned user "${member.user.tag}" from guild "${member.guild.name}"`))
|
||||
.catch(error => logger.error(`failed to autoban user "${member.user.tag}" from guild "${member.guild.name}": ${error}`));
|
||||
} else {
|
||||
logger.info(`user "${member.user.tag}" is not on the autoban list for "${member.guild.name}"`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user