mirror of
https://github.com/Expand-sys/ccashbot
synced 2025-12-16 23:52:14 +11:00
good
This commit is contained in:
parent
9eb1aa15fc
commit
9422e6e2b3
24 changed files with 4436 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.env
|
||||||
|
node_modules
|
||||||
BIN
action.png
Normal file
BIN
action.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
82
build/config.gypi
Normal file
82
build/config.gypi
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
25
commands/fun/google.js
Normal file
25
commands/fun/google.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
const googleIt = require("google-it");
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'google',
|
||||||
|
description: 'Google shit or something',
|
||||||
|
execute(message, args) {
|
||||||
|
let query = ''
|
||||||
|
for(i in args){
|
||||||
|
query += args[i]+' '
|
||||||
|
}
|
||||||
|
console.log(query)
|
||||||
|
|
||||||
|
googleIt({'limit': 1, 'query': query, 'disableConsole':'true'}).then(results => {
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle(results[0].title)
|
||||||
|
.setURL(results[0].link)
|
||||||
|
.setDescription(results[0].snippet)
|
||||||
|
message.reply(embed)
|
||||||
|
}).catch(e => {
|
||||||
|
// any possible errors that might have occurred (like no Internet connection)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
};
|
||||||
18
commands/fun/leet.js
Normal file
18
commands/fun/leet.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
const leet = require("../../helpers/leetspeak");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'leet',
|
||||||
|
description: 'leet speak translator',
|
||||||
|
async execute(message, args) {
|
||||||
|
var text = ''
|
||||||
|
for(i in args){
|
||||||
|
text += args[i]+' '
|
||||||
|
}
|
||||||
|
text = text.slice(0, text.length-1)
|
||||||
|
console.log(text)
|
||||||
|
let output = await leet.convertInput(text)
|
||||||
|
message.reply(output)
|
||||||
|
},
|
||||||
|
};
|
||||||
7
commands/fun/ping.js
Normal file
7
commands/fun/ping.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
name: 'ping',
|
||||||
|
description: 'Ping!',
|
||||||
|
execute(message, args) {
|
||||||
|
message.channel.send('Pong!');
|
||||||
|
},
|
||||||
|
};
|
||||||
197
commands/fun/steam.js
Normal file
197
commands/fun/steam.js
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
const steamer = require('../../helpers/steamer.js')
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const appid = require('appid')
|
||||||
|
const request = require("request-promise-cache");
|
||||||
|
const fs = require("fs")
|
||||||
|
function getID(input){
|
||||||
|
return new Promise (async (resolve, reject) => {
|
||||||
|
let result = await appid(input)
|
||||||
|
resolve(result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const api = "https://api.steampowered.com/ISteamApps/GetAppList/v0002/";
|
||||||
|
let options = {
|
||||||
|
url: api,
|
||||||
|
cacheKey: api,
|
||||||
|
cacheTLL: 1000*60*60
|
||||||
|
};
|
||||||
|
function name_exact(name) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request(options).then(data => {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
resolve(data.applist.apps.filter(a => a.name === name)[0]);
|
||||||
|
}).catch(e => reject(e));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
name: 'steam',
|
||||||
|
description: 'steam getter!',
|
||||||
|
async execute(message, args) {
|
||||||
|
if(args[0] == 'game'){
|
||||||
|
let input = "";
|
||||||
|
for(i=1; i<args.length;i++){
|
||||||
|
input += args[i]+' '
|
||||||
|
}
|
||||||
|
input = input.slice(0, input.length-1)
|
||||||
|
console.log(input)
|
||||||
|
let appID
|
||||||
|
try{
|
||||||
|
appID = await name_exact(input)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
message.reply('Couldnt find game')
|
||||||
|
}
|
||||||
|
if (!appID){
|
||||||
|
message.reply('oi couldnt find game')
|
||||||
|
}else {
|
||||||
|
let game
|
||||||
|
try{
|
||||||
|
game = await steamer.game(appID.appid)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error);
|
||||||
|
message.reply('Couldnt find game')
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(game)
|
||||||
|
|
||||||
|
if (game[appID.appid] == undefined){
|
||||||
|
message.reply('ahhh fuck cant find shit with these eyes')
|
||||||
|
}else{
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle('Game: '+game[appID.appid].data.name)
|
||||||
|
.setURL(game[appID.appid].data.website)
|
||||||
|
.setDescription(game[appID.appid].data.short_description)
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Steam app ID', value: game[appID.appid].data.steam_appid },
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter('heh nice');
|
||||||
|
message.reply(embed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0] == "ownedGames"){
|
||||||
|
let steamID = args[1]
|
||||||
|
if(args[1] = 'url'){
|
||||||
|
let response = await steamer.getSteamID(args[2])
|
||||||
|
steamID = response.response.steamid
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!steamID) {
|
||||||
|
return res.status(500).send("SteamID parameter required.");
|
||||||
|
}
|
||||||
|
let games
|
||||||
|
try{
|
||||||
|
games = await steamer.ownedGames(steamID)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
if(games == null){
|
||||||
|
message.reply("could not find player "+ args[1] )
|
||||||
|
}else{
|
||||||
|
message.reply(steamID+" Owns "+games.response.game_count+" games on steam")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0] == "recentgames"){
|
||||||
|
let steamID = args[1]
|
||||||
|
if(args[1] = 'url'){
|
||||||
|
let response = await steamer.getSteamID(args[2])
|
||||||
|
steamID = response.response.steamid
|
||||||
|
}
|
||||||
|
if (!steamID) {
|
||||||
|
return res.status(500).send("SteamID parameter required.");
|
||||||
|
}
|
||||||
|
let games
|
||||||
|
try{
|
||||||
|
games = await steamer.recentGames(steamID)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
if (games.response.total_count == 0){
|
||||||
|
message.reply('Sad bois, no games played in the last 2 weeks')
|
||||||
|
}else{
|
||||||
|
let gameslist = games.response.games
|
||||||
|
let description = '';
|
||||||
|
for(games in gameslist){
|
||||||
|
description += gameslist[games].name+'\n'
|
||||||
|
}
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle(args[2]+'\'s recent games')
|
||||||
|
.setDescription(description)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter('heh nice');
|
||||||
|
message.reply(embed)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0] == 'user'){
|
||||||
|
let steamID = args[1]
|
||||||
|
if(args[1] = 'url'){
|
||||||
|
let response = await steamer.getSteamID(args[2])
|
||||||
|
steamID = response.response.steamid
|
||||||
|
}
|
||||||
|
if (!steamID) {
|
||||||
|
return res.status(500).send("SteamID parameter required.");
|
||||||
|
}
|
||||||
|
let user
|
||||||
|
try{
|
||||||
|
user = await steamer.user(steamID)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
console.log(user.response.players[0])
|
||||||
|
player = user.response.players[0]
|
||||||
|
let created = new Date(player.timecreated * 1000).toLocaleDateString('en-au')
|
||||||
|
let online = new Date(player.lastlogoff * 1000).toLocaleDateString('en-au')
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle(player.profileurl)
|
||||||
|
.setURL(player.profileurl)
|
||||||
|
.setAuthor(player.personaname)
|
||||||
|
.setThumbnail(player.avatarfull)
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Date Created', value: created },
|
||||||
|
{ name: 'Last online', value: online}
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter('heh made by expand#0001');
|
||||||
|
message.reply(embed)
|
||||||
|
}
|
||||||
|
if(args[0] == 'gamenews'){
|
||||||
|
let input = "";
|
||||||
|
for(i=1; i<args.length;i++){
|
||||||
|
input += args[i]+' '
|
||||||
|
}
|
||||||
|
input = input.slice(0, input.length-1)
|
||||||
|
console.log(input)
|
||||||
|
let appID
|
||||||
|
try{
|
||||||
|
appID = await name_exact(input)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
message.reply('Couldnt find game')
|
||||||
|
}
|
||||||
|
let news = await steamer.gameNews(appID.appid)
|
||||||
|
console.log(news.appnews.newsitems[0])
|
||||||
|
time = new Date(news.appnews.newsitems[0].date*1000).toLocaleDateString('en-au')
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle(news.appnews.newsitems[0].title)
|
||||||
|
.setURL(news.appnews.newsitems[0].url)
|
||||||
|
.setTimestamp(time)
|
||||||
|
.setFooter(news.appnews.newsitems[0].feedlabel);
|
||||||
|
message.reply(embed)
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
//gameNews,
|
||||||
15
commands/moderation/kick.js
Normal file
15
commands/moderation/kick.js
Normal 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}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
19
commands/moderation/prune.js
Normal file
19
commands/moderation/prune.js
Normal 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!');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
23
commands/moderation/rolekick.js
Normal file
23
commands/moderation/rolekick.js
Normal 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')
|
||||||
|
}
|
||||||
|
}
|
||||||
35
commands/moderation/whitelist.js
Normal file
35
commands/moderation/whitelist.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const got = require("got");
|
||||||
|
|
||||||
|
String.prototype.splice = function (idx, rem, str) {
|
||||||
|
return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "whitelist",
|
||||||
|
description: "Whitelist a user on the minecraft server",
|
||||||
|
guildOnly: true,
|
||||||
|
permissions: "KICK_MEMBERS",
|
||||||
|
async execute(message, args) {
|
||||||
|
if (!args) {
|
||||||
|
return message.reply("You need to type the user you want whitelisted");
|
||||||
|
} else {
|
||||||
|
let file = JSON.parse(fs.readFileSync("../whitelist.json"));
|
||||||
|
let player = await got(
|
||||||
|
"https://api.mojang.com/users/profiles/minecraft/" + args[0]
|
||||||
|
);
|
||||||
|
player = JSON.parse(player.body);
|
||||||
|
player.id = player.id.splice(8, 0, "-");
|
||||||
|
player.id = player.id.splice(13, 0, "-");
|
||||||
|
player.id = player.id.splice(18, 0, "-");
|
||||||
|
player.id = player.id.splice(23, 0, "-");
|
||||||
|
let format = {
|
||||||
|
uuid: player.id,
|
||||||
|
name: player.name,
|
||||||
|
};
|
||||||
|
file.push(format);
|
||||||
|
fs.writeFileSync("../whitelist.json", JSON.stringify(file));
|
||||||
|
return message.reply("Whitelisted user: " + player.name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
12
commands/utility/args-info.js
Normal file
12
commands/utility/args-info.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
module.exports = {
|
||||||
|
name: 'args-info',
|
||||||
|
description: 'Information about the arguments provided.',
|
||||||
|
args: true,
|
||||||
|
execute(message, args) {
|
||||||
|
if (args[0] === 'foo') {
|
||||||
|
return message.channel.send('bar');
|
||||||
|
}
|
||||||
|
|
||||||
|
message.channel.send(`First argument: ${args[0]}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
16
commands/utility/avatar.js
Normal file
16
commands/utility/avatar.js
Normal 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
46
commands/utility/help.js
Normal 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 });
|
||||||
|
},
|
||||||
|
};
|
||||||
30
commands/utility/reload.js
Normal file
30
commands/utility/reload.js
Normal 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}\``);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
7
commands/utility/server.js
Normal file
7
commands/utility/server.js
Normal 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}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
7
commands/utility/user-info.js
Normal file
7
commands/utility/user-info.js
Normal 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}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
91
helpers/leetspeak.js
Normal file
91
helpers/leetspeak.js
Normal 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 }
|
||||||
168
helpers/steamer.js
Normal file
168
helpers/steamer.js
Normal file
|
|
@ -0,0 +1,168 @@
|
||||||
|
const baseURL = "https://api.steampowered.com/"
|
||||||
|
const token = '6CF857296B7A47108E148C40164822B2'
|
||||||
|
var http = require("http");
|
||||||
|
const superagent = require("superagent")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function createRequest(interfaceName, method, version) {
|
||||||
|
let url = `${baseURL}/${interfaceName}/${method}/v${version}/?key=${token}&format=json`;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ownedGames(steamID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.get(`http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=${token}&steamid=${steamID}&format=json`, function(res){
|
||||||
|
var body = ""
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
let json
|
||||||
|
try{
|
||||||
|
json = JSON.parse(body)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
resolve(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function getSteamID(vanityUrl) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.get(`http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=${token}&vanityurl=${vanityUrl}&format=json`, function(res){
|
||||||
|
var body = ""
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
let json
|
||||||
|
try{
|
||||||
|
json = JSON.parse(body)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
resolve(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function recentGames(steamID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.get(`http://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v0001/?key=${token}&steamid=${steamID}&format=json`, function(res){
|
||||||
|
var body = ""
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
let json
|
||||||
|
try{
|
||||||
|
json = JSON.parse(body)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
resolve(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function user(steamID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.get(`http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${token}&steamids=${steamID}`, function(res){
|
||||||
|
var body = ""
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
let json
|
||||||
|
try{
|
||||||
|
json = JSON.parse(body)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
resolve(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function gameNews(appID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.get(`http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=${appID}&count=1&maxlength=300&format=json`, function(res){
|
||||||
|
var body = ""
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
let json
|
||||||
|
try{
|
||||||
|
json = JSON.parse(body)
|
||||||
|
} catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
resolve(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function game(appID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let req = http.request(`https://store.steampowered.com/api/appdetails?appids=${appID}`, function(res){
|
||||||
|
var body = [];
|
||||||
|
res.on('data', function(chunk) {
|
||||||
|
body.push(chunk);
|
||||||
|
});
|
||||||
|
res.on('end', function() {
|
||||||
|
try {
|
||||||
|
body = JSON.parse(Buffer.concat(body).toString());
|
||||||
|
} catch(e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
resolve(body);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (e) => {
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
// send the request
|
||||||
|
req.end();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
getSteamID,
|
||||||
|
game,
|
||||||
|
gameNews,
|
||||||
|
user,
|
||||||
|
createRequest,
|
||||||
|
ownedGames,
|
||||||
|
recentGames,
|
||||||
|
}
|
||||||
97
index.js
Normal file
97
index.js
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const { Client, MessageAttachment, Collection } = require("discord.js");
|
||||||
|
const dotenv = require("dotenv");
|
||||||
|
dotenv.config();
|
||||||
|
const prefix = process.env.PREFIX;
|
||||||
|
|
||||||
|
const client = new Client();
|
||||||
|
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("message", 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);
|
||||||
BIN
json.sqlite
Normal file
BIN
json.sqlite
Normal file
Binary file not shown.
3509
package-lock.json
generated
Normal file
3509
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
30
package.json
Normal file
30
package.json
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "discordbot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://10.10.4.20:3000/HarrisonDubois/discordbot.git"
|
||||||
|
},
|
||||||
|
"author": "Expand",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"appid": "^1.0.3",
|
||||||
|
"discord.js": "^12.5.3",
|
||||||
|
"dotenv": "^10.0.0",
|
||||||
|
"file-type": "^16.5.0",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
|
"get-pixels": "^3.3.2",
|
||||||
|
"google-it": "^1.6.2",
|
||||||
|
"got": "^11.8.2",
|
||||||
|
"moment": "^2.29.1",
|
||||||
|
"node-fetch": "^2.6.1",
|
||||||
|
"request-promise-cache": "^2.0.1",
|
||||||
|
"superagent": "^6.1.0",
|
||||||
|
"unirest": "^0.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
status.png
Normal file
BIN
status.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in a new issue