mirror of
https://github.com/Expand-sys/expandschatbot
synced 2026-03-22 12:37:10 +11:00
aaa
This commit is contained in:
parent
b92ceef221
commit
c117c6a55f
18 changed files with 4546 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.env
|
||||||
|
node_modules
|
||||||
|
|
@ -1 +1,6 @@
|
||||||
|
# discordbot
|
||||||
|
|
||||||
|
# ccashbot
|
||||||
|
# expandschatbot
|
||||||
|
# expandschatbot
|
||||||
# expandschatbot
|
# expandschatbot
|
||||||
|
|
|
||||||
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
|
||||||
|
}
|
||||||
|
}
|
||||||
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!');
|
||||||
|
},
|
||||||
|
};
|
||||||
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')
|
||||||
|
}
|
||||||
|
}
|
||||||
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}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
147
index.js
Normal file
147
index.js
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const {
|
||||||
|
Client,
|
||||||
|
MessageAttachment,
|
||||||
|
Intents,
|
||||||
|
Collection,
|
||||||
|
} = require("discord.js");
|
||||||
|
const dotenv = require("dotenv");
|
||||||
|
const { env } = require("process");
|
||||||
|
const got = require("got")
|
||||||
|
dotenv.config();
|
||||||
|
const { Configuration, OpenAIApi } = require("openai");
|
||||||
|
|
||||||
|
const configuration = new Configuration({
|
||||||
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
|
});
|
||||||
|
const openai = new OpenAIApi(configuration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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("message", async (message) => {
|
||||||
|
if (message.mentions.members.first()){
|
||||||
|
if (message.mentions.members.first().user.id == 216882708012466176) {
|
||||||
|
let question = message.content.split(" ")
|
||||||
|
question.shift()
|
||||||
|
question = question.join(" ")
|
||||||
|
|
||||||
|
response = await openai.createCompletion({
|
||||||
|
model: "text-davinci-003",
|
||||||
|
|
||||||
|
prompt: `${question}`,
|
||||||
|
temperature: 0.5,
|
||||||
|
max_tokens: 500,
|
||||||
|
top_p: 0.3,
|
||||||
|
frequency_penalty: 0.5,
|
||||||
|
presence_penalty: 0.0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
console.log(response.data)
|
||||||
|
message.reply(response.data.choices[0].text)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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.
2537
package-lock.json
generated
Normal file
2537
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
29
package.json
Normal file
29
package.json
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "discordbot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Expand-sys/ccashbot"
|
||||||
|
},
|
||||||
|
"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",
|
||||||
|
"got": "^11.8.2",
|
||||||
|
"moment": "^2.29.1",
|
||||||
|
"node-fetch": "^2.6.1",
|
||||||
|
"openai": "^3.1.0",
|
||||||
|
"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