first on gitea
This commit is contained in:
1 parent
27894dac21
commit
94bf054772
22 files changed
+4829
-4657
No files matched your search
+139
-139
@@ -1,139 +1,139 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
const logger = require('../../utils/logger');
|
||||
|
||||
async function getAvailableCapes(username) {
|
||||
const capes =[];
|
||||
|
||||
const mojangReq = await Promise.allSettled([
|
||||
fetch(`https://api.ashcon.app/mojang/v2/user/${username}`),
|
||||
]);
|
||||
|
||||
if (mojangReq.status === 'fulfilled' && mojangReq.value.ok) {
|
||||
const mojangData = await mojangReq.value.json();
|
||||
if (mojangData.textures && mojangData.textures.cape) {
|
||||
capes.push({
|
||||
source: 'Official (Equipped)',
|
||||
url: mojangData.textures.cape.url
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return capes;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'mc',
|
||||
description: `request different information about a minecraft user`,
|
||||
aliases: ['minecraft'],
|
||||
usage: 'mc <username>',
|
||||
|
||||
async execute(client, message, args) {
|
||||
var embed;
|
||||
|
||||
let sent = await message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<a:loading_icon:1366587619890302998> fetching...',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
|
||||
const username = args[0];
|
||||
if (!username) {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> please provide a valid minecraft username!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return await sent.edit({ content: null, embeds: [embed] });
|
||||
}
|
||||
|
||||
const uuid_res = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
|
||||
|
||||
const uuid = await uuid_res.json().then(res => res.id).catch(err => {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> cannot fetch uuid!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return null;
|
||||
});
|
||||
|
||||
const res = await fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${uuid}`);
|
||||
const data = await res.json().then(res => res).catch(err => {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> cannot fetch data!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return null;
|
||||
});
|
||||
|
||||
getAvailableCapes(`${data.name}`).then(capes => {
|
||||
logger.debug(`found ${capes.length} cape(s):`);
|
||||
logger.debug(capes);
|
||||
});
|
||||
|
||||
if (!data) return await sent.edit({ content: null, embeds: [embed] });
|
||||
|
||||
const skin = await fetch (`https://minotar.net/helm/${data.name}/420.png`).then(res => res.url).catch(err => null);
|
||||
|
||||
const capes = data.properties[0].value;
|
||||
const decoded_capes = Buffer.from(capes, 'base64').toString('utf-8');
|
||||
const cape_url = JSON.parse(decoded_capes).textures.CAPE ? JSON.parse(decoded_capes).textures.CAPE.url : null;
|
||||
|
||||
logger.debug(`[mc] fetched data for "${username}": ${JSON.stringify(data)}`);
|
||||
logger.debug(`[mc] fetched cape data for "${username}": ${JSON.stringify(cape_url)}`);
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${data.name}](https://namemc.com/profile/${data.name})**`,
|
||||
fields: [
|
||||
{ name: 'uuid', value: `${data.id}`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
thumbnail: {
|
||||
url: skin,
|
||||
height: 1024,
|
||||
width: 1024,
|
||||
},
|
||||
};
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
const logger = require('../../utils/logger');
|
||||
|
||||
async function getAvailableCapes(username) {
|
||||
const capes =[];
|
||||
|
||||
const mojangReq = await Promise.allSettled([
|
||||
fetch(`https://api.ashcon.app/mojang/v2/user/${username}`),
|
||||
]);
|
||||
|
||||
if (mojangReq.status === 'fulfilled' && mojangReq.value.ok) {
|
||||
const mojangData = await mojangReq.value.json();
|
||||
if (mojangData.textures && mojangData.textures.cape) {
|
||||
capes.push({
|
||||
source: 'Official (Equipped)',
|
||||
url: mojangData.textures.cape.url
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return capes;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'mc',
|
||||
description: `request different information about a minecraft user`,
|
||||
aliases: ['minecraft'],
|
||||
usage: 'mc <username>',
|
||||
|
||||
async execute(client, message, args) {
|
||||
var embed;
|
||||
|
||||
let sent = await message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<a:loading_icon:1366587619890302998> fetching...',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
|
||||
const username = args[0];
|
||||
if (!username) {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> please provide a valid minecraft username!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return await sent.edit({ content: null, embeds: [embed] });
|
||||
}
|
||||
|
||||
const uuid_res = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
|
||||
|
||||
const uuid = await uuid_res.json().then(res => res.id).catch(err => {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> cannot fetch uuid!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return null;
|
||||
});
|
||||
|
||||
const res = await fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${uuid}`);
|
||||
const data = await res.json().then(res => res).catch(err => {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
description: '<:no:1481811955592466492> cannot fetch data!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return null;
|
||||
});
|
||||
|
||||
getAvailableCapes(`${data.name}`).then(capes => {
|
||||
logger.debug(`found ${capes.length} cape(s):`);
|
||||
logger.debug(capes);
|
||||
});
|
||||
|
||||
if (!data) return await sent.edit({ content: null, embeds: [embed] });
|
||||
|
||||
const skin = await fetch (`https://minotar.net/helm/${data.name}/420.png`).then(res => res.url).catch(err => null);
|
||||
|
||||
const capes = data.properties[0].value;
|
||||
const decoded_capes = Buffer.from(capes, 'base64').toString('utf-8');
|
||||
const cape_url = JSON.parse(decoded_capes).textures.CAPE ? JSON.parse(decoded_capes).textures.CAPE.url : null;
|
||||
|
||||
logger.debug(`[mc] fetched data for "${username}": ${JSON.stringify(data)}`);
|
||||
logger.debug(`[mc] fetched cape data for "${username}": ${JSON.stringify(cape_url)}`);
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${data.name}](https://namemc.com/profile/${data.name})**`,
|
||||
fields: [
|
||||
{ name: 'uuid', value: `${data.id}`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
thumbnail: {
|
||||
url: skin,
|
||||
height: 1024,
|
||||
width: 1024,
|
||||
},
|
||||
};
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
+423
-386
@@ -1,386 +1,423 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const logger = require('../../utils/logger');
|
||||
|
||||
async function fetch_avatar(id) {
|
||||
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();
|
||||
logger.debug(`[fetch_avatar] ${JSON.stringify(data)}`);
|
||||
if (data.data && data.data[0] && data.data[0].imageUrl) {
|
||||
logger.debug(`[fetch_avatar] fetched avatar for user id ${id}: ${data.data[0].imageUrl}`);
|
||||
return data.data[0].imageUrl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetch_item_thumb(id) {
|
||||
const res = await fetch(`https://thumbnails.roproxy.com/v1/assets?assetIds=${id}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
logger.debug(`[fetch_item_thumb] ${JSON.stringify(data)}`);
|
||||
if (data.data && data.data[0] && data.data[0].imageUrl) {
|
||||
logger.debug(`[fetch_item_thumb] fetched item thumbnail for item id ${id}: ${data.data[0].imageUrl}`);
|
||||
return data.data[0].imageUrl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function to_unix_timestamp(dateString) {
|
||||
const unixSeconds = Math.floor(new Date(dateString).getTime() / 1000);
|
||||
logger.debug(unixSeconds);
|
||||
return unixSeconds;
|
||||
}
|
||||
|
||||
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>',
|
||||
|
||||
async execute(client, message) {
|
||||
var embed = {};
|
||||
const args = message.content.split(' ').slice(1);
|
||||
|
||||
if (args.length < 2) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> please provide a subcommand and an argument!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const subcommand = args[0].toLowerCase();
|
||||
const argument = args.slice(1).join(' ');
|
||||
|
||||
let sent = await message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<a:loading_icon:1366587619890302998> fetching...',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
|
||||
let latency = Date.now() - message.createdTimestamp;
|
||||
let apiLatency = Math.round(client.ws.ping);
|
||||
|
||||
if (subcommand === 'user' || subcommand === 'u') {
|
||||
try {
|
||||
const res = await fetch(`https://users.roproxy.com/v1/usernames/users`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` },
|
||||
body: JSON.stringify({ usernames: [argument], excludeBannedUsers: false })
|
||||
});
|
||||
const data = await res.json();
|
||||
logger.debug(`[rbx] fetched user data (roblox, standard) for "${argument}": ${JSON.stringify(data)}`);
|
||||
|
||||
if (!data.data || !data.data[0]) {
|
||||
throw new Error('User not found');
|
||||
}
|
||||
const extra_res = await fetch(`https://users.roproxy.com/v1/users/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` }
|
||||
});
|
||||
const extra_data = await extra_res.json();
|
||||
logger.debug(`[rbx] fetched user data (roblox, extra) for "${argument}": ${JSON.stringify(extra_data)}`);
|
||||
|
||||
const r_res = await fetch(`https://api.rolimons.com/players/v1/playerinfo/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
let r_data = {};
|
||||
if (r_res.ok) {
|
||||
r_data = await r_res.json();
|
||||
} else {
|
||||
logger.warn(`[rbx] Failed to fetch rolimons playerinfo for id ${data.data[0].id}: HTTP ${r_res.status}`);
|
||||
r_data = {};
|
||||
}
|
||||
logger.debug(`[rbx] fetched user data (rolimons) for "${argument}": ${JSON.stringify(r_data)}`);
|
||||
|
||||
const ra_res = await fetch(`https://api.rolimons.com/players/v1/playerassets/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const ra_data = await ra_res.json();
|
||||
logger.debug(`[rbx] fetched user data (rolimons, assets) for "${argument}": ${JSON.stringify(ra_data)}`);
|
||||
|
||||
if (!data.data || !data.data[0]) {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> could not find a roblox user with that username!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}
|
||||
} else {
|
||||
const user = data.data[0];
|
||||
const avatarUrl = await fetch_avatar(user.id);
|
||||
|
||||
const hasCheckmark = user.hasVerifiedBadge;
|
||||
const hasPremium = r_data.premium;
|
||||
const isOnline = ra_data.isOnline;
|
||||
|
||||
const viewInvRes = await fetch(`https://inventory.roproxy.com/v1/users/${user.id}/can-view-inventory`);
|
||||
const isInvPublic = (await viewInvRes.json()).canView;
|
||||
|
||||
const formatted_desc = (extra_data.description || "no description")
|
||||
.split('\n')
|
||||
.map(line => line.trim() ? `-# *${line}*` : '')
|
||||
.join('\n');
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${user.displayName}](https://www.roblox.com/users/${user.id}/profile)** [(${user.name})](https://www.rolimons.com/player/${user.id}) ${isOnline ? "<:online:1482657396362055826>" : "<:offline:1482657564650115073>"} ${hasPremium ? "<:premium:1482660040358760602>" : ""} ${hasCheckmark ? "<:Verified:1376786225486364823>" : ""}\n${formatted_desc}`,
|
||||
fields: [
|
||||
{ name: 'id', value: String(extra_data.id), inline: true },
|
||||
{ name: 'rap', value: String(r_data.rap), inline: true },
|
||||
{ name: 'value', value: String(r_data.value), inline: true },
|
||||
{ name: 'inventory', value: `${isInvPublic ? 'public' : 'private'}`, inline: true },
|
||||
{ name: 'terminated', value: String(r_data.terminated), inline: true },
|
||||
{ name: 'date created', value: `<t:${to_unix_timestamp(String(extra_data.created))}:f>`, inline: true },
|
||||
{ name: 'last online', value: `${isOnline ? "now" : "<t:" + r_data.last_online + ":f>"}`, inline: true },
|
||||
],
|
||||
thumbnail: {
|
||||
url: avatarUrl,
|
||||
height: 420,
|
||||
width: 420,
|
||||
},
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch user data for "${argument}":`, err);
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> could not fetch 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`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
const p_res = await fetch(`https://thumbnails.roproxy.com/v1/assets?assetIds=${argument}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
const resale_res = await fetch(`https://economy.roproxy.com/v1/assets/${argument}/resale-data`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
|
||||
const item = await res.json();
|
||||
logger.debug(`[rbx] fetched item data (roblox) for "${argument}": ${JSON.stringify(item)}`);
|
||||
|
||||
const resale_data = await resale_res.json();
|
||||
logger.debug(`[rbx] fetched resale data for "${argument}": ${JSON.stringify(resale_data)}`);
|
||||
|
||||
let itemsJson;
|
||||
try {
|
||||
const itemsPath = path.resolve(process.cwd(), 'items.json');
|
||||
const itemsRaw = fs.readFileSync(itemsPath, 'utf8');
|
||||
itemsJson = JSON.parse(itemsRaw);
|
||||
if (itemsJson.items && itemsJson.items[argument]) {
|
||||
logger.debug(`[rbx] found item ${argument} in items.json: ${JSON.stringify(itemsJson.items[argument])}`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn(`[rbx] could not read items.json: ${e.message}`);
|
||||
}
|
||||
|
||||
let item_e = itemsJson.items[argument];
|
||||
|
||||
var hasAcronym = false;
|
||||
if (item_e[1] = "") {
|
||||
hasAcronym = false;
|
||||
} else {
|
||||
hasAcronym = true;
|
||||
}
|
||||
|
||||
const item_thumb = await fetch_item_thumb(item.AssetId);
|
||||
const is_offsale = item.IsForSale;
|
||||
|
||||
const is_limited = item.IsLimited;
|
||||
const is_limited_unique = item.IsLimitedUnique;
|
||||
|
||||
const is_limited_at_all = is_limited || is_limited_unique;
|
||||
|
||||
const limited_string = is_limited ? (is_limited_unique ? "true (unique)" : "true") : "false";
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `[${item.Name}](https://roblox.com/catalog/${argument}) ${hasAcronym ? item_e[1] : ""}\n-# *${item.Description}*`,
|
||||
fields: [
|
||||
{ name: "id", value: `${item.AssetId}`, inline: true },
|
||||
{ name: "price", value: `${is_offsale ? "offsale" : item.PriceInRobux}`, inline: true },
|
||||
{ name: "limited", value: `${limited_string}`, inline: true },
|
||||
{ name: "rap", value: `${is_limited_at_all ? resale_data.recentAveragePrice : "0"}`, inline: true },
|
||||
{ name: "creator", value: `${item.Creator.Name}`, inline: true },
|
||||
],
|
||||
thumbnail: {
|
||||
url: item_thumb,
|
||||
height: 420,
|
||||
width: 420
|
||||
},
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch item data for "${argument}":`, err);
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> could not fetch data for item "${argument}"!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}
|
||||
}
|
||||
} else if (subcommand === 'group') {
|
||||
try {
|
||||
const res = await fetch(`https://groups.roproxy.com/v1/groups/${argument}`);
|
||||
const p_res = await fetch(`https://thumbnails.roproxy.com/v1/groups/icons?groupIds=${argument}&size=420x420&format=Png&isCircular=false`);
|
||||
|
||||
if (!res.ok) throw new Error();
|
||||
if (!p_res.ok) throw new Error();
|
||||
|
||||
const group = await res.json();
|
||||
const p_json = await p_res.json();
|
||||
logger.debug(`${JSON.stringify(p_json)}`);
|
||||
const thumb = (p_json && p_json.data && p_json.data[0]) ? p_json.data[0].imageUrl : null;
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${group.name}](https://roblox.com/communities/${argument})**\n-# *${group.description || "no description"}*`,
|
||||
thumbnail: {
|
||||
url: thumb,
|
||||
height: 420,
|
||||
width: 420
|
||||
},
|
||||
fields: [
|
||||
{ name: "members", value: `${group.memberCount}`, inline: true },
|
||||
{ name: "owner", value: `${group.owner.username}`, inline: true },
|
||||
{ name: "shout", value: `${group.shout}`, inline: true },
|
||||
{ name: "open", value: `${group.publicEntryAllowed}`, inline: true },
|
||||
{ name: "verified", value: `${group.hasVerifiedBadge}`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch group data for "${argument}":`, err);
|
||||
embed.title = 'Error';
|
||||
embed.description = 'Failed to fetch group data.';
|
||||
}
|
||||
} else if (subcommand === 'game') {
|
||||
try {
|
||||
const res = await fetch(`https://games.roproxy.com/v1/games?universeIds=${argument}`);
|
||||
if (!res.ok) throw new Error();
|
||||
const data = await res.json();
|
||||
if (!data.data || !data.data[0]) {
|
||||
embed.title = 'Game Not Found';
|
||||
embed.description = `Could not find a Roblox game with the universe ID **${argument}**.`;
|
||||
} else {
|
||||
const game = data.data[0];
|
||||
embed.title = `Roblox Game: ${game.name}`;
|
||||
embed.description = game.description || 'No description.';
|
||||
embed.thumbnail.url = `https://www.roproxy.com/asset-thumbnail/image?assetId=${game.rootPlaceId}&width=420&height=420&format=png`;
|
||||
embed.fields = [
|
||||
{ name: 'Creator', value: game.creator.name, inline: true },
|
||||
{ name: 'Playing', value: game.playing.toLocaleString(), inline: true },
|
||||
{ name: 'Visits', value: game.visits.toLocaleString(), inline: true }
|
||||
];
|
||||
}
|
||||
} catch (err) {
|
||||
embed.title = 'Error';
|
||||
embed.description = 'Failed to fetch game data.';
|
||||
}
|
||||
}/* else {
|
||||
embed.title = 'invalid subcommand';
|
||||
embed.description = 'Valid subcommands: `user`, `item`, `group`, `game`';
|
||||
}*/
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const logger = require('../../utils/logger');
|
||||
|
||||
async function fetch_avatar(id) {
|
||||
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();
|
||||
logger.debug(`[fetch_avatar] ${JSON.stringify(data)}`);
|
||||
if (data.data && data.data[0] && data.data[0].imageUrl) {
|
||||
logger.debug(`[fetch_avatar] fetched avatar for user id ${id}: ${data.data[0].imageUrl}`);
|
||||
return data.data[0].imageUrl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetch_item_thumb(id) {
|
||||
const res = await fetch(`https://thumbnails.roproxy.com/v1/assets?assetIds=${id}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
logger.debug(`[fetch_item_thumb] ${JSON.stringify(data)}`);
|
||||
if (data.data && data.data[0] && data.data[0].imageUrl) {
|
||||
logger.debug(`[fetch_item_thumb] fetched item thumbnail for item id ${id}: ${data.data[0].imageUrl}`);
|
||||
return data.data[0].imageUrl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function to_unix_timestamp(dateString) {
|
||||
const unixSeconds = Math.floor(new Date(dateString).getTime() / 1000);
|
||||
logger.debug(unixSeconds);
|
||||
return unixSeconds;
|
||||
}
|
||||
|
||||
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>\n.rbx avatar <username>',
|
||||
|
||||
async execute(client, message) {
|
||||
var embed = {};
|
||||
const args = message.content.split(' ').slice(1);
|
||||
|
||||
if (args.length < 2) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> please provide a subcommand and an argument!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const subcommand = args[0].toLowerCase();
|
||||
const argument = args.slice(1).join(' ');
|
||||
|
||||
let sent = await message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<a:loading_icon:1366587619890302998> fetching...',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
|
||||
let latency = Date.now() - message.createdTimestamp;
|
||||
let apiLatency = Math.round(client.ws.ping);
|
||||
|
||||
if (subcommand === 'user' || subcommand === 'u') {
|
||||
try {
|
||||
const res = await fetch(`https://users.roproxy.com/v1/usernames/users`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` },
|
||||
body: JSON.stringify({ usernames: [argument], excludeBannedUsers: false })
|
||||
});
|
||||
const data = await res.json();
|
||||
logger.debug(`[rbx] fetched user data (roblox, standard) for "${argument}": ${JSON.stringify(data)}`);
|
||||
|
||||
if (!data.data || !data.data[0]) {
|
||||
throw new Error('User not found');
|
||||
}
|
||||
const extra_res = await fetch(`https://users.roproxy.com/v1/users/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` }
|
||||
});
|
||||
const extra_data = await extra_res.json();
|
||||
logger.debug(`[rbx] fetched user data (roblox, extra) for "${argument}": ${JSON.stringify(extra_data)}`);
|
||||
|
||||
const r_res = await fetch(`https://api.rolimons.com/players/v1/playerinfo/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
let r_data = {};
|
||||
if (r_res.ok) {
|
||||
r_data = await r_res.json();
|
||||
} else {
|
||||
logger.warn(`[rbx] Failed to fetch rolimons playerinfo for id ${data.data[0].id}: HTTP ${r_res.status}`);
|
||||
r_data = {};
|
||||
}
|
||||
logger.debug(`[rbx] fetched user data (rolimons) for "${argument}": ${JSON.stringify(r_data)}`);
|
||||
|
||||
const ra_res = await fetch(`https://api.rolimons.com/players/v1/playerassets/${data.data[0].id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const ra_data = await ra_res.json();
|
||||
logger.debug(`[rbx] fetched user data (rolimons, assets) for "${argument}": ${JSON.stringify(ra_data)}`);
|
||||
|
||||
if (!data.data || !data.data[0]) {
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> could not find a roblox user with that username!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}
|
||||
} else {
|
||||
const user = data.data[0];
|
||||
const avatarUrl = await fetch_avatar(user.id);
|
||||
|
||||
const hasCheckmark = user.hasVerifiedBadge;
|
||||
const hasPremium = r_data.premium;
|
||||
const isOnline = ra_data.isOnline;
|
||||
|
||||
const viewInvRes = await fetch(`https://inventory.roproxy.com/v1/users/${user.id}/can-view-inventory`);
|
||||
const isInvPublic = (await viewInvRes.json()).canView;
|
||||
|
||||
const formatted_desc = (extra_data.description || "no description")
|
||||
.split('\n')
|
||||
.map(line => line.trim() ? `-# *${line}*` : '')
|
||||
.join('\n');
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${user.displayName}](https://www.roblox.com/users/${user.id}/profile)** [(${user.name})](https://www.rolimons.com/player/${user.id}) ${isOnline ? "<:online:1482657396362055826>" : "<:offline:1482657564650115073>"} ${hasPremium ? "<:premium:1482660040358760602>" : ""} ${hasCheckmark ? "<:Verified:1376786225486364823>" : ""}\n${formatted_desc}`,
|
||||
fields: [
|
||||
{ name: 'id', value: String(extra_data.id), inline: true },
|
||||
{ name: 'rap', value: String(r_data.rap), inline: true },
|
||||
{ name: 'value', value: String(r_data.value), inline: true },
|
||||
{ name: 'inventory', value: `${isInvPublic ? 'public' : 'private'}`, inline: true },
|
||||
{ name: 'terminated', value: String(r_data.terminated), inline: true },
|
||||
{ name: 'date created', value: `<t:${to_unix_timestamp(String(extra_data.created))}:f>`, inline: true },
|
||||
{ name: 'last online', value: `${isOnline ? "now" : "<t:" + r_data.last_online + ":f>"}`, inline: true },
|
||||
],
|
||||
thumbnail: {
|
||||
url: avatarUrl,
|
||||
height: 420,
|
||||
width: 420,
|
||||
},
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch user data for "${argument}":`, err);
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> could not fetch data for user "${argument}"!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
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`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
const p_res = await fetch(`https://thumbnails.roproxy.com/v1/assets?assetIds=${argument}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
const resale_res = await fetch(`https://economy.roproxy.com/v1/assets/${argument}/resale-data`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
|
||||
}
|
||||
});
|
||||
|
||||
const item = await res.json();
|
||||
logger.debug(`[rbx] fetched item data (roblox) for "${argument}": ${JSON.stringify(item)}`);
|
||||
|
||||
const resale_data = await resale_res.json();
|
||||
logger.debug(`[rbx] fetched resale data for "${argument}": ${JSON.stringify(resale_data)}`);
|
||||
|
||||
let itemsJson;
|
||||
try {
|
||||
const itemsPath = path.resolve(process.cwd(), 'items.json');
|
||||
const itemsRaw = fs.readFileSync(itemsPath, 'utf8');
|
||||
itemsJson = JSON.parse(itemsRaw);
|
||||
if (itemsJson.items && itemsJson.items[argument]) {
|
||||
logger.debug(`[rbx] found item ${argument} in items.json: ${JSON.stringify(itemsJson.items[argument])}`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn(`[rbx] could not read items.json: ${e.message}`);
|
||||
}
|
||||
|
||||
let item_e = itemsJson.items[argument];
|
||||
|
||||
var hasAcronym = false;
|
||||
if (item_e[1] = "") {
|
||||
hasAcronym = false;
|
||||
} else {
|
||||
hasAcronym = true;
|
||||
}
|
||||
|
||||
const item_thumb = await fetch_item_thumb(item.AssetId);
|
||||
const is_offsale = item.IsForSale;
|
||||
|
||||
const is_limited = item.IsLimited;
|
||||
const is_limited_unique = item.IsLimitedUnique;
|
||||
|
||||
const is_limited_at_all = is_limited || is_limited_unique;
|
||||
|
||||
const limited_string = is_limited ? (is_limited_unique ? "true (unique)" : "true") : "false";
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `[${item.Name}](https://roblox.com/catalog/${argument}) ${hasAcronym ? item_e[1] : ""}\n-# *${item.Description}*`,
|
||||
fields: [
|
||||
{ name: "id", value: `${item.AssetId}`, inline: true },
|
||||
{ name: "price", value: `${is_offsale ? "offsale" : item.PriceInRobux}`, inline: true },
|
||||
{ name: "limited", value: `${limited_string}`, inline: true },
|
||||
{ name: "rap", value: `${is_limited_at_all ? resale_data.recentAveragePrice : "0"}`, inline: true },
|
||||
{ name: "creator", value: `${item.Creator.Name}`, inline: true },
|
||||
],
|
||||
thumbnail: {
|
||||
url: item_thumb,
|
||||
height: 420,
|
||||
width: 420
|
||||
},
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch item data for "${argument}":`, err);
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> could not fetch data for item "${argument}"!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}
|
||||
}
|
||||
} else if (subcommand === 'group') {
|
||||
try {
|
||||
const res = await fetch(`https://groups.roproxy.com/v1/groups/${argument}`);
|
||||
const p_res = await fetch(`https://thumbnails.roproxy.com/v1/groups/icons?groupIds=${argument}&size=420x420&format=Png&isCircular=false`);
|
||||
|
||||
if (!res.ok) throw new Error();
|
||||
if (!p_res.ok) throw new Error();
|
||||
|
||||
const group = await res.json();
|
||||
const p_json = await p_res.json();
|
||||
logger.debug(`${JSON.stringify(p_json)}`);
|
||||
const thumb = (p_json && p_json.data && p_json.data[0]) ? p_json.data[0].imageUrl : null;
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**[${group.name}](https://roblox.com/communities/${argument})**\n-# *${group.description || "no description"}*`,
|
||||
thumbnail: {
|
||||
url: thumb,
|
||||
height: 420,
|
||||
width: 420
|
||||
},
|
||||
fields: [
|
||||
{ name: "members", value: `${group.memberCount}`, inline: true },
|
||||
{ name: "owner", value: `${group.owner.username}`, inline: true },
|
||||
{ name: "shout", value: `${group.shout}`, inline: true },
|
||||
{ name: "open", value: `${group.publicEntryAllowed}`, inline: true },
|
||||
{ name: "verified", value: `${group.hasVerifiedBadge}`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(`[rbx] failed to fetch group data for "${argument}":`, err);
|
||||
embed.title = 'Error';
|
||||
embed.description = 'Failed to fetch group data.';
|
||||
}
|
||||
} else if (subcommand === 'game') {
|
||||
try {
|
||||
const res = await fetch(`https://games.roproxy.com/v1/games?universeIds=${argument}`);
|
||||
if (!res.ok) throw new Error();
|
||||
const data = await res.json();
|
||||
if (!data.data || !data.data[0]) {
|
||||
embed.title = 'Game Not Found';
|
||||
embed.description = `Could not find a Roblox game with the universe ID **${argument}**.`;
|
||||
} else {
|
||||
const game = data.data[0];
|
||||
embed.title = `Roblox Game: ${game.name}`;
|
||||
embed.description = game.description || 'No description.';
|
||||
embed.thumbnail.url = `https://www.roproxy.com/asset-thumbnail/image?assetId=${game.rootPlaceId}&width=420&height=420&format=png`;
|
||||
embed.fields = [
|
||||
{ name: 'Creator', value: game.creator.name, inline: true },
|
||||
{ name: 'Playing', value: game.playing.toLocaleString(), inline: true },
|
||||
{ name: 'Visits', value: game.visits.toLocaleString(), inline: true }
|
||||
];
|
||||
}
|
||||
} catch (err) {
|
||||
embed.title = 'Error';
|
||||
embed.description = 'Failed to fetch game data.';
|
||||
}
|
||||
}/* else {
|
||||
embed.title = 'invalid subcommand';
|
||||
embed.description = 'Valid subcommands: `user`, `item`, `group`, `game`';
|
||||
}*/
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'lists all available commands or shows info about a specific one',
|
||||
aliases: ['h', 'commands'],
|
||||
usage: 'help [command]',
|
||||
|
||||
execute(client, message, args) {
|
||||
var embed;
|
||||
const prefix = process.env.PREFIX || '!';
|
||||
|
||||
// Show info for a specific command
|
||||
if (args.length > 0) {
|
||||
const name = args[0].toLowerCase();
|
||||
const command = client.commands.get(name);
|
||||
|
||||
if (!command) {
|
||||
return message.reply(`no command found for \`${name}\`.`);
|
||||
}
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**${prefix}${command.name}**\n-# ${command.description || 'no description'}`,
|
||||
fields: [
|
||||
{ name: 'aliases', value: command.aliases.map((a) => `\`${prefix}${a}\``).join(', ') },
|
||||
{ name: 'usage', value: `\`${prefix}${command.usage}\`` }
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
return message.reply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
// Build a deduplicated command list (ignore aliases pointing to the same command)
|
||||
const seen = new Set();
|
||||
const commandList = [];
|
||||
|
||||
for (const command of client.commands.values()) {
|
||||
if (seen.has(command.name)) continue;
|
||||
seen.add(command.name);
|
||||
commandList.push(`\`${prefix}${command.name}\` — ${command.description || 'no description'}`);
|
||||
}
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `-# use ${prefix}help <command> for more details`,
|
||||
fields: [
|
||||
{ name: 'commands', value: commandList.join('\n') },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
return message.reply({ embeds: [embed] });
|
||||
},
|
||||
};
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'lists all available commands or shows info about a specific one',
|
||||
aliases: ['h', 'commands'],
|
||||
usage: 'help [command]',
|
||||
|
||||
execute(client, message, args) {
|
||||
var embed;
|
||||
const prefix = process.env.PREFIX || '!';
|
||||
|
||||
// Show info for a specific command
|
||||
if (args.length > 0) {
|
||||
const name = args[0].toLowerCase();
|
||||
const command = client.commands.get(name);
|
||||
|
||||
if (!command) {
|
||||
return message.reply(`no command found for \`${name}\`.`);
|
||||
}
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `**${prefix}${command.name}**\n-# ${command.description || 'no description'}`,
|
||||
fields: [
|
||||
{ name: 'aliases', value: command.aliases.map((a) => `\`${prefix}${a}\``).join(', ') },
|
||||
{ name: 'usage', value: `\`${prefix}${command.usage}\`` }
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
return message.reply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
// Build a deduplicated command list (ignore aliases pointing to the same command)
|
||||
const seen = new Set();
|
||||
const commandList = [];
|
||||
|
||||
for (const command of client.commands.values()) {
|
||||
if (seen.has(command.name)) continue;
|
||||
seen.add(command.name);
|
||||
commandList.push(`\`${prefix}${command.name}\` — ${command.description || 'no description'}`);
|
||||
}
|
||||
|
||||
embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `-# use ${prefix}help <command> for more details`,
|
||||
fields: [
|
||||
{ name: 'commands', value: commandList.join('\n') },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
return message.reply({ embeds: [embed] });
|
||||
},
|
||||
};
|
||||
@@ -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(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,88 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'ban',
|
||||
description: `ban a user from the current server`,
|
||||
aliases: ['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() || client.users.cache.get(args[0]);
|
||||
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 ban!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const reason = args.slice(1).join(' ') || 'no reason provided (twitter)';
|
||||
const duration = args[2] ? parseInt(args[2]) : null;
|
||||
|
||||
try {
|
||||
await message.guild.members.ban(user, { reason });
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:check:1481811973447356496> ${user.username} has been banned!`,
|
||||
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 ban the user!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'ban',
|
||||
description: `ban a user from the current server`,
|
||||
aliases: ['b'],
|
||||
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() || client.users.cache.get(args[0]);
|
||||
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 ban!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const reason = args.slice(1).join(' ') || 'no reason provided (twitter)';
|
||||
const duration = args[2] ? parseInt(args[2]) : null;
|
||||
|
||||
try {
|
||||
await message.guild.members.ban(user, { reason });
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:check:1481811973447356496> ${user.username} has been banned!`,
|
||||
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 ban the user!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,88 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'kick',
|
||||
description: `kick a user from the current server`,
|
||||
aliases: ['kick'],
|
||||
usage: 'kick <user> [reason]',
|
||||
|
||||
async execute(client, message, args) {
|
||||
if (!message.member.permissions.has('KickMembers')) {
|
||||
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() || client.users.cache.get(args[0]);
|
||||
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 ban!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const reason = args.slice(1).join(' ') || 'no reason provided (twitter)';
|
||||
const duration = args[2] ? parseInt(args[2]) : null;
|
||||
|
||||
try {
|
||||
await message.guild.members.kick(user, { reason });
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:check:1481811973447356496> ${user.username} has been kicked!`,
|
||||
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 ban the user!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'kick',
|
||||
description: `kick a user from the current server`,
|
||||
aliases: ['kick'],
|
||||
usage: 'kick <user> [reason]',
|
||||
|
||||
async execute(client, message, args) {
|
||||
if (!message.member.permissions.has('KickMembers')) {
|
||||
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() || client.users.cache.get(args[0]);
|
||||
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 ban!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
const reason = args.slice(1).join(' ') || 'no reason provided (twitter)';
|
||||
const duration = args[2] ? parseInt(args[2]) : null;
|
||||
|
||||
try {
|
||||
await message.guild.members.kick(user, { reason });
|
||||
message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:check:1481811973447356496> ${user.username} has been kicked!`,
|
||||
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 ban the user!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,84 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'autorole',
|
||||
description: `assign a role to new members when they join the server`,
|
||||
aliases: ['ar'],
|
||||
usage: 'autorole <role>',
|
||||
|
||||
async execute(client, message, args) {
|
||||
if (!message.member.permissions.has('Administrator')) {
|
||||
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 role = message.mentions.roles.first() || message.guild.roles.cache.get(args[0]);
|
||||
|
||||
if (!role) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> please provide a valid role!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
// add the role to a json file for the guild and save it to be used when new members join (if the role is already in the database, update it to the new role)
|
||||
const dbPath = path.join(__dirname, '..', '..', '..', 'db.json');
|
||||
|
||||
let db = {};
|
||||
if (fs.existsSync(dbPath)) {
|
||||
db = JSON.parse(fs.readFileSync(dbPath, 'utf8'));
|
||||
}
|
||||
|
||||
if (!db.autoroles) {
|
||||
db.autoroles = {};
|
||||
}
|
||||
|
||||
db.autoroles[message.guild.id] = role.id;
|
||||
|
||||
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> "${role.name}" has been set as the autorole!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'autorole',
|
||||
description: `assign a role to new members when they join the server`,
|
||||
aliases: ['ar'],
|
||||
usage: 'autorole <role>',
|
||||
|
||||
async execute(client, message, args) {
|
||||
if (!message.member.permissions.has('Administrator')) {
|
||||
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 role = message.mentions.roles.first() || message.guild.roles.cache.get(args[0]);
|
||||
|
||||
if (!role) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: '<:no:1481811955592466492> please provide a valid role!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
// add the role to a json file for the guild and save it to be used when new members join (if the role is already in the database, update it to the new role)
|
||||
const dbPath = path.join(__dirname, '..', '..', '..', 'db.json');
|
||||
|
||||
let db = {};
|
||||
if (fs.existsSync(dbPath)) {
|
||||
db = JSON.parse(fs.readFileSync(dbPath, 'utf8'));
|
||||
}
|
||||
|
||||
if (!db.autoroles) {
|
||||
db.autoroles = {};
|
||||
}
|
||||
|
||||
db.autoroles[message.guild.id] = role.id;
|
||||
|
||||
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> "${role.name}" has been set as the autorole!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}]
|
||||
});
|
||||
}
|
||||
};
|
||||
+43
-43
@@ -1,43 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'ping',
|
||||
description: `test the bot's latency to discord's servers and api`,
|
||||
aliases: ['pong'],
|
||||
usage: 'ping',
|
||||
|
||||
async execute(client, message) {
|
||||
const sent = await message.reply('pinging');
|
||||
const latency = sent.createdTimestamp - message.createdTimestamp;
|
||||
const apiLatency = Math.round(client.ws.ping);
|
||||
|
||||
const embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: 'fuck you!!!! 🖕',
|
||||
fields: [
|
||||
{ name: '# of cmds loaded', value: `**${client.commands.size}**`, inline: true },
|
||||
{ name: 'bot latency', value: `**${latency}ms**`, inline: true },
|
||||
{ name: 'api latency', value: `**${apiLatency}ms**`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
thumbnail: {
|
||||
url: client.user.displayAvatarURL(),
|
||||
height: 1024,
|
||||
width: 1024,
|
||||
},
|
||||
};
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'ping',
|
||||
description: `test the bot's latency to discord's servers and api`,
|
||||
aliases: ['pong'],
|
||||
usage: 'ping',
|
||||
|
||||
async execute(client, message) {
|
||||
const sent = await message.reply('pinging');
|
||||
const latency = sent.createdTimestamp - message.createdTimestamp;
|
||||
const apiLatency = Math.round(client.ws.ping);
|
||||
|
||||
const embed = {
|
||||
color: 0x8aa2b3,
|
||||
title: '',
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: 'fuck you!!!! 🖕',
|
||||
fields: [
|
||||
{ name: '# of cmds loaded', value: `**${client.commands.size}**`, inline: true },
|
||||
{ name: 'bot latency', value: `**${latency}ms**`, inline: true },
|
||||
{ name: 'api latency', value: `**${apiLatency}ms**`, inline: true },
|
||||
],
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
thumbnail: {
|
||||
url: client.user.displayAvatarURL(),
|
||||
height: 1024,
|
||||
width: 1024,
|
||||
},
|
||||
};
|
||||
|
||||
await sent.edit({ content: null, embeds: [embed] });
|
||||
},
|
||||
};
|
||||
+61
-61
@@ -1,61 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'purge',
|
||||
description: `delete a specified number of messages from the current channel`,
|
||||
aliases: ['clear', 'p'],
|
||||
usage: 'purge <number>',
|
||||
|
||||
async execute(client, message) {
|
||||
if (!message.member.permissions.has('ManageMessages')) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
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 args = message.content.split(' ').slice(1);
|
||||
const amount = parseInt(args[0]) + 1;
|
||||
|
||||
if (isNaN(amount) || amount < 1 || amount > 100) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
description: '<:no:1481811955592466492> please provide a number between 1 and 100!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
const deletedMessages = await message.channel.bulkDelete(amount, true);
|
||||
const reply = await message.channel.send({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> successfully deleted ${deletedMessages.size - 1} messages!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}],
|
||||
});
|
||||
setTimeout(() => reply.delete().catch(() => { }), 5000);
|
||||
},
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const { time } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'purge',
|
||||
description: `delete a specified number of messages from the current channel`,
|
||||
aliases: ['clear', 'p'],
|
||||
usage: 'purge <number>',
|
||||
|
||||
async execute(client, message) {
|
||||
if (!message.member.permissions.has('ManageMessages')) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
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 args = message.content.split(' ').slice(1);
|
||||
const amount = parseInt(args[0]) + 1;
|
||||
|
||||
if (isNaN(amount) || amount < 1 || amount > 100) {
|
||||
return message.reply({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
description: '<:no:1481811955592466492> please provide a number between 1 and 100!',
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
const deletedMessages = await message.channel.bulkDelete(amount, true);
|
||||
const reply = await message.channel.send({
|
||||
content: null, embeds: [{
|
||||
color: 0x8aa2b3,
|
||||
author: {
|
||||
name: message.author.username,
|
||||
icon_url: message.author.displayAvatarURL(),
|
||||
},
|
||||
description: `<:no:1481811955592466492> successfully deleted ${deletedMessages.size - 1} messages!`,
|
||||
footer: {
|
||||
text: `twitter @ ${message.guild.name}`,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
}],
|
||||
});
|
||||
setTimeout(() => reply.delete().catch(() => { }), 5000);
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user