boilerplate

This commit is contained in:
Expand-sys 2022-06-29 08:34:30 +10:00
parent fa78267e92
commit 43965d860b
15 changed files with 1688 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.env
node_modules

82
build/config.gypi Normal file
View file

@ -0,0 +1,82 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"dcheck_always_on": 0,
"debug_nghttp2": "false",
"debug_node": "false",
"enable_lto": "false",
"enable_pgo_generate": "false",
"enable_pgo_use": "false",
"error_on_warn": "false",
"force_dynamic_crt": 0,
"gas_version": "2.30",
"host_arch": "x64",
"icu_data_in": "../../deps/icu-tmp/icudt68l.dat",
"icu_endianness": "l",
"icu_gyp_path": "tools/icu/icu-generic.gyp",
"icu_path": "deps/icu-small",
"icu_small": "false",
"icu_ver_major": "68",
"is_debug": 0,
"llvm_version": "0.0",
"napi_build_version": "7",
"node_byteorder": "little",
"node_debug_lib": "false",
"node_enable_d8": "false",
"node_install_npm": "true",
"node_module_version": 88,
"node_no_browser_globals": "false",
"node_prefix": "/",
"node_release_urlbase": "https://nodejs.org/download/release/",
"node_section_ordering_info": "",
"node_shared": "false",
"node_shared_brotli": "false",
"node_shared_cares": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "false",
"node_shared_nghttp2": "false",
"node_shared_openssl": "false",
"node_shared_zlib": "false",
"node_tag": "",
"node_target_type": "executable",
"node_use_bundled_v8": "true",
"node_use_dtrace": "false",
"node_use_etw": "false",
"node_use_node_code_cache": "true",
"node_use_node_snapshot": "true",
"node_use_openssl": "true",
"node_use_v8_platform": "true",
"node_with_ltcg": "false",
"node_without_node_options": "false",
"openssl_fips": "",
"openssl_is_fips": "false",
"ossfuzz": "false",
"shlib_suffix": "so.88",
"target_arch": "x64",
"v8_enable_31bit_smis_on_64bit_arch": 0,
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_enable_inspector": 1,
"v8_enable_lite_mode": 0,
"v8_enable_object_print": 1,
"v8_enable_pointer_compression": 0,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 1,
"v8_promise_internal_field_count": 1,
"v8_random_seed": 0,
"v8_trace_maps": 0,
"v8_use_siphash": 1,
"want_separate_host_toolset": 0,
"nodedir": "/home/harrisond/.cache/node-gyp/15.11.0",
"standalone_static_library": 1
}
}

View file

@ -0,0 +1,15 @@
module.exports = {
name: 'kick',
description: 'Tag a member and kick them (but not really).',
guildOnly: true,
permissions: 'KICK_MEMBERS',
execute(message) {
if (!message.mentions.users.size) {
return message.reply('you need to tag a user in order to kick them!');
}
const taggedUser = message.mentions.users.first();
message.channel.send(`You wanted to kick: ${taggedUser.username}`);
},
};

View file

@ -0,0 +1,19 @@
module.exports = {
name: 'prune',
description: 'Prune up to 99 messages.',
permissions: 'MANAGE_MESSAGES',
execute(message, args) {
const amount = parseInt(args[0]) + 1;
if (isNaN(amount)) {
return message.reply('that doesn\'t seem to be a valid number.');
} else if (amount <= 1 || amount > 100) {
return message.reply('you need to input a number between 1 and 99.');
}
message.channel.bulkDelete(amount, true).catch(err => {
console.error(err);
message.channel.send('there was an error trying to prune messages in this channel!');
});
},
};

View file

@ -0,0 +1,23 @@
module.exports = {
name: 'rolekick',
description: 'kick an entire role worth of peeps.',
guildOnly: true,
permissions: 'KICK_MEMBERS',
execute(message, args) {
console.log('fetching roles')
message.guild.roles.fetch({cache: true})
console.log('fetching members')
message.guild.members.fetch({cache: true})
.then()
const roleID = message.content.slice(13, message.content.length-1)
console.log(roleID)
let membersWithRole = message.guild.roles.cache.get(roleID).members.map(member => member.id);
for(i=0;i<membersWithRole.length; i++){
console.log(membersWithRole[i])
let member = message.guild.member(membersWithRole[i])
member.kick('purge the infidels')
};
message.reply('Mass Role puge complete')
}
}

View file

@ -0,0 +1,16 @@
module.exports = {
name: 'avatar',
description: 'Get the avatar URL of the tagged user(s), or your own avatar.',
aliases: ['icon', 'pfp'],
execute(message) {
if (!message.mentions.users.size) {
return message.channel.send(`Your avatar: <${message.author.displayAvatarURL({ dynamic: true })}>`);
}
const avatarList = message.mentions.users.map(user => {
return `${user.username}'s avatar: <${user.displayAvatarURL({ dynamic: true })}>`;
});
message.channel.send(avatarList);
},
};

46
commands/utility/help.js Normal file
View file

@ -0,0 +1,46 @@
const prefix = process.env.PREFIX
module.exports = {
name: 'help',
description: 'List all of my commands or info about a specific command.',
aliases: ['commands'],
usage: '[command name]',
cooldown: 5,
execute(message, args) {
const data = [];
const { commands } = message.client;
if (!args.length) {
data.push('Here\'s a list of all my commands:');
data.push(commands.map(command => command.name).join(', '));
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);
return message.author.send(data, { split: true })
.then(() => {
if (message.channel.type === 'dm') return;
message.reply('I\'ve sent you a DM with all my commands!');
})
.catch(error => {
console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
message.reply('it seems like I can\'t DM you!');
});
}
const name = args[0].toLowerCase();
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
if (!command) {
return message.reply('that\'s not a valid command!');
}
data.push(`**Name:** ${command.name}`);
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
if (command.description) data.push(`**Description:** ${command.description}`);
if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
message.channel.send(data, { split: true });
},
};

View file

@ -0,0 +1,30 @@
const fs = require('fs');
module.exports = {
name: 'reload',
description: 'Reloads a command',
args: true,
execute(message, args) {
const commandName = args[0].toLowerCase();
const command = message.client.commands.get(commandName)
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) {
return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
}
const commandFolders = fs.readdirSync('./commands');
const folderName = commandFolders.find(folder => fs.readdirSync(`./commands/${folder}`).includes(`${commandName}.js`));
delete require.cache[require.resolve(`../${folderName}/${command.name}.js`)];
try {
const newCommand = require(`../${folderName}/${command.name}.js`);
message.client.commands.set(newCommand.name, newCommand);
message.channel.send(`Command \`${command.name}\` was reloaded!`);
} catch (error) {
console.error(error);
message.channel.send(`There was an error while reloading a command \`${command.name}\`:\n\`${error.message}\``);
}
},
};

View file

@ -0,0 +1,7 @@
module.exports = {
name: 'server',
description: 'Display info about this server.',
execute(message) {
message.channel.send(`Server name: ${message.guild.name}\nTotal members: ${message.guild.memberCount}`);
},
};

View file

@ -0,0 +1,7 @@
module.exports = {
name: 'user-info',
description: 'Display info about yourself.',
execute(message) {
message.channel.send(`Your username: ${message.author.username}\nYour ID: ${message.author.id}`);
},
};

64
helpers/ccash.js Normal file
View file

@ -0,0 +1,64 @@
const db = require("quick.db");
const got = require("got");
api = process.env.CCASHAPIURL;
async function link(disc, userpass) {
let verified = await got.post(process.env.CCASHAPIURL + "BankF/vpass", {
json: {
name: user,
attempt: pass,
},
responseType: "json",
});
if (verified.body.value == 1) {
console.log("verified");
if (db.get("links", { discorduser: disc.id }).ccashuser != user) {
db.delete("links", {
discorduser: disc.id,
});
db.push("links", {
discorduser: disc.id,
ccashuser: user,
attempt: pass,
});
return true;
} else {
db.push("links", {
discorduser: disc.id,
ccashuser: user,
attempt: pass,
});
}
}
return false;
}
async function checkbal(disc, user) {
if (user != undefined) {
balance = await got(`${api}/user/balance`, {
headers: {
Accept: "application/json",
},
searchParams: {
name: user,
},
});
balance = parseInt(balance.body);
return balance;
} else {
let usernm = db.get("links").filter((a) => a.discorduser == disc.id)[0]
.ccashuser;
console.log(usernm);
balance = await got(`${api}/user/balance`, {
headers: {
Accept: "application/json",
},
searchParams: {
name: usernm,
},
});
balance = parseInt(balance.body);
return balance;
}
console.log(balance);
}
module.exports = { link, checkbal };

91
helpers/leetspeak.js Normal file
View file

@ -0,0 +1,91 @@
const alphabetBasic = {
'a': '4',
'b': '8',
'e': '3',
'f': 'f',
'g': '6', // or 9
'i': '1', // or |
'o': '0',
's': '5',
't': '7' // or +
}
const alphabetAdvanced = {
'c': '(', // or k or |< or /<
'd': '<|',
'h': '|-|',
'k': '|<', // or /<
'l': '|', // or 1
'm': '|\\/|',
'n': '|\\|',
'p': '|2',
'u': '|_|',
'v': '/', // or \/
'w': '//', // or \/\/
'x': '><',
'y': '\'/'
}
const alphabetReversed = [
[/(\|\\\/\|)/g, 'm'],
[/(\|\\\|)/g, 'n'],
[/(\()/g, 'c'],
[/(<\|)/g, 'd'],
[/\|-\|/g, 'h'],
[/(\|<)/g, 'k'],
[/(\|2)/g, 'p'],
[/(\|_\|)/g, 'u'],
[/(\/\/)/g, 'w'],
[/(><)/g, 'x'],
[/(\|)/g, 'l'],
[/(\'\/)/g, 'y'],
[/(\/)/g, 'v'],
[/(1)/g, 'i'],
[/(0)/g, 'o'],
[/(3)/g, 'e'],
[/(4)/g, 'a'],
[/(5)/g, 's'],
[/(6)/g, 'g'],
[/(7)/g, 't'],
[/(8)/g, 'b'],
[/(ph)/g, 'f'],
]
// Convert input into l33t
const convertInput = (text, useAdvanced = 'n') => {
for (let i = 0; i < text.length; i++) {
let alphabet
let letter = text[i].toLowerCase()
if (useAdvanced.toLowerCase() === 'y') {
// Use advanced l33t speak alphabet
alphabet = alphabetBasic[letter] ? alphabetBasic[letter] : alphabetAdvanced[letter]
} else {
// Use basic l33t speak alphabet
alphabet = alphabetBasic[letter]
}
if (alphabet) {
text = text.replace(text[i], alphabet)
}
}
// Show the result in console
console.log(text)
return text
}
const convertInputReverse = (text) => {
text = text.toLowerCase()
alphabetReversed.map((x) => {
text = text.replace(x[0], x[1])
})
console.log(text)
return text
}
module.exports = { convertInput, convertInputReverse }

112
index.js Normal file
View file

@ -0,0 +1,112 @@
const fs = require("fs");
const {
Client,
MessageAttachment,
Intents,
Collection
} = require("discord.js");
const dotenv = require("dotenv");
dotenv.config();
const prefix = process.env.PREFIX;
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_PRESENCES
]
});
client.commands = new Collection();
client.cooldowns = new Collection();
const commandFolders = fs.readdirSync("./commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./commands/${folder}`)
.filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}
client.once("ready", () => {
console.log("Ready!");
});
client.on("messageCreate", async message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/);
const commandName = args.shift().toLowerCase();
const command =
client.commands.get(commandName) ||
client.commands.find(
cmd => cmd.aliases && cmd.aliases.includes(commandName)
);
if (!command) return;
if (command.guildOnly && message.channel.type === "dm") {
return message.reply("I can't execute that command inside DMs!");
}
if (command.permissions) {
const authorPerms = message.channel.permissionsFor(message.author);
if (!authorPerms || !authorPerms.has(command.permissions)) {
return message.reply("You can not do this!");
}
}
if (command.args && !args.length) {
let reply = `You didn't provide any arguments, ${message.author}!`;
if (command.usage) {
reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
}
return message.channel.send(reply);
}
const { cooldowns } = client;
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
return message.reply(
`please wait ${timeLeft.toFixed(
1
)} more second(s) before reusing the \`${command.name}\` command.`
);
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
try {
command.execute(message, args, client);
} catch (error) {
console.error(error);
message.reply("there was an error trying to execute that command!");
}
});
client.login(process.env.TOKEN);

1164
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

10
package.json Normal file
View file

@ -0,0 +1,10 @@
{
"dependencies": {
"discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"fs": "^0.0.1-security",
"got": "^12.0.4",
"moment": "^2.29.3",
"node-fetch": "^3.2.3"
}
}