Skip to content
Snippets Groups Projects
Commit 2d182a7f authored by Miniontoby's avatar Miniontoby :writing_hand_tone1:
Browse files

Version 0.0.1

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 451 additions and 0 deletions
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true,
"ts": false
},
"parserOptions": {
"ecmaVersion": 2021
},
"rules": {
"arrow-spacing": ["warn", { "before": true, "after": true }],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"indent": ["error", "tab"],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
}
}
\ No newline at end of file
node_modules
config.json
.env
\ No newline at end of file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\index.js"
}
]
}
\ No newline at end of file
{
"editor.insertSpaces": false
}
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageActionRow, MessageSelectMenu } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('apply')
.setDescription('Apply for staff!')
.setDMPermission(false),
async execute(interaction) {
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('apply_modal')
.setPlaceholder('Nothing selected')
.addOptions([
{
label: 'Staff',
description: 'Apply for staff',
value: 'staff',
},
{
label: 'Builder',
description: 'Apply for builder',
value: 'builder',
},
{
label: 'Developer',
description: 'Apply for developer',
value: 'developer',
},
]),
);
await interaction.reply({ content: 'Select the rank you want to apply for!', components: [row] });
},
};
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!')
.addStringOption(option =>
option.setName('input')
.setDescription('The input to echo back')
.setRequired(true)),
async execute(interaction) {
await interaction.reply(`You said: ${interaction.options.getString('input')}!`);
},
};
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('faq')
.setDescription('Replies with the faq URL!')
.setDMPermission(false),
async execute(interaction) {
await interaction.reply('**FAQ**:\n\nView: https://zeronetwork.ircforever.org/faq/ \nAdd: https://zeronetwork.ircforever.org/faq/add.php ');
},
};
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Get info about a user or a server!')
.addSubcommand(subcommand =>
subcommand
.setName('user')
.setDescription('Info about a user')
.addUserOption(option => option.setName('target').setDescription('The user')))
.addSubcommand(subcommand =>
subcommand
.setName('server')
.setDescription('Info about the server'))
.setDMPermission(false),
async execute(interaction) {
if (interaction.options.getSubcommand() === 'user') {
const user = interaction.options.getUser('target');
if (user) {
await interaction.reply(`Username: ${user.username}\nID: ${user.id}`);
}
else {
await interaction.reply(`Your username: ${interaction.user.username}\nYour ID: ${interaction.user.id}`);
}
}
else if (interaction.options.getSubcommand() === 'server') {
await interaction.reply(`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`);
}
},
};
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageActionRow, Modal, TextInputComponent } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
const modal = new Modal()
.setCustomId('ping')
.setTitle('My Modal');
const favoriteColorInput = new TextInputComponent()
.setCustomId('favoriteColorInput')
.setLabel('What\'s your favorite color?')
.setStyle('SHORT');
const hobbiesInput = new TextInputComponent()
.setCustomId('hobbiesInput')
.setLabel('What\'s some of your favorite hobbies?')
.setStyle('PARAGRAPH');
const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
},
};
\ No newline at end of file
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('website')
.setDescription('Replies with the website URL!')
.setDMPermission(false),
async execute(interaction) {
await interaction.reply('**Website**:\n\nOfficial: https://www.zeronetwork.ircforever.org/ \nExtra: https://zeronetwork.ircforever.org/ ');
},
};
\ No newline at end of file
const fs = require('node:fs');
const path = require('node:path');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, token } = require('./config.json');
const globalcommands = [],
guildcommands = [],
commandsPath = path.join(__dirname, 'commands'),
commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')),
rest = new REST({ version: '9' }).setToken(token),
servers = ['793533219554328587', '986538932672004196'];
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if (!command.data) continue;
command.data.dm_permission = (command.data?.dm_permission == undefined) ? true : command.data.dm_permission;
if (command.data.dm_permission == true) {
if (command.contextdata) globalcommands.push(command.contextdata.toJSON());
globalcommands.push(command.data.toJSON());
}
else {
if (command.contextdata) guildcommands.push(command.contextdata.toJSON());
guildcommands.push(command.data.toJSON());
}
}
(async () => {
try {
console.log('Started refreshing application (/) commands.');
for (const server in servers) {
const guildId = servers[server];
await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: guildcommands })
.then(() => console.log(`Successfully registered ${guildcommands.length} Guild application commands.`))
.catch(console.error);
}
await rest.put(Routes.applicationCommands(clientId), { body: globalcommands })
.then(() => console.log(`Successfully registered ${globalcommands.length} Global application commands.`))
.catch(console.error);
console.log('Successfully reloaded application (/) commands.');
}
catch (error) {
console.error(error);
}
})();
async function execute(thing, interaction, errormessage) {
if (!thing) return;
try {
await thing.execute(interaction);
}
catch (error) {
console.error(error);
await interaction.reply({ content: errormessage, ephemeral: true });
}
}
module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (interaction.isButton()) {
const button = client.buttons.get(interaction.customId);
execute(button, interaction, 'There was an error while executing this button!');
}
else if (interaction.isCommand()) {
const command = client.commands.get(interaction.commandName);
execute(command, interaction, 'There was an error while executing this command!');
}
else if (interaction.isModalSubmit()) {
const modal = client.modals.get(interaction.customId);
execute(modal, interaction, 'There was an error while executing this modal!');
}
else if (interaction.isSelectMenu()) {
const selectmenu = client.selectmenus.get(interaction.customId);
execute(selectmenu, interaction, 'There was an error while executing this select menu!');
}
},
};
\ No newline at end of file
module.exports = {
name: 'ready',
once: true,
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
},
};
\ No newline at end of file
const { MessageActionRow, TextInputComponent, Modal } = require('discord.js');
function newComponent(type, customId, label, style, required = false) {
let comp = false;
if (type == 'text') {
comp = new TextInputComponent()
.setCustomId(customId)
.setLabel(label)
.setStyle(style)
.setRequired(required);
}
const output = new MessageActionRow();
if (comp) output.addComponents(comp);
return output;
}
const email = newComponent('text', 'email', 'What\'s your email address?', 'SHORT', false),
ign = newComponent('text', 'ign', 'What\'s your name in Minecraft? (IGN)', 'SHORT', true),
age = newComponent('text', 'age', 'What\'s your age?', 'SHORT', true),
mic = newComponent('text', 'mic', 'Do you have access to a working mic? (yes no)', 'SHORT', true),
status = newComponent('text', 'status', 'What is your current status? (staff owner)', 'SHORT', true),
playtime = newComponent('text', 'playtime', 'What\'s your playtime? (in hours)', 'SHORT', true),
onlinetime_day = newComponent('text', 'onlinetime_day', 'How much can you be online in a day?', 'SHORT', true),
onlinetime_week = newComponent('text', 'onlinetime_week', 'How much can you be online in a week?', 'SHORT', true),
timezone = newComponent('text', 'timezone', 'What\'s your timezone?', 'SHORT', true),
why_wana = newComponent('text', 'why_wana', 'Why do you want to be staff?', 'SHORT', true),
why_good = newComponent('text', 'why_good', 'Why are you good staff?', 'SHORT', true),
understand = newComponent('text', 'understand', 'If you ask about apply you prob get denied', 'SHORT', true);
const modal1 = new Modal().setCustomId('apply_modal1');
modal1.addComponents(email, ign, age, mic, status);
const modal2 = new Modal().setCustomId('apply_modal2');
modal2.addComponents(playtime, onlinetime_day, onlinetime_week, timezone);
const modal3 = new Modal().setCustomId('apply_modal3');
modal3.addComponents(why_wana, why_good, understand);
module.exports = { modal1, modal2, modal3 };
\ No newline at end of file
index.js 0 → 100644
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Intents } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.buttons = new Collection();
client.commands = new Collection();
client.modals = new Collection();
client.selectmenus = new Collection();
client.applyInfo = new Collection();
const buttonsPath = path.join(__dirname, 'interactions', 'buttons');
const buttonFiles = fs.readdirSync(buttonsPath).filter(file => file.endsWith('.js'));
for (const file of buttonFiles) {
const filePath = path.join(buttonsPath, file);
const button = require(filePath);
client.buttons.set(button.name, button);
}
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
}
const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, async (...args) => event.execute(...args, client));
}
else {
client.on(event.name, async (...args) => event.execute(...args, client));
}
}
const modalsPath = path.join(__dirname, 'interactions', 'modals');
const modalsFiles = fs.readdirSync(modalsPath).filter(file => file.endsWith('.js'));
for (const file of modalsFiles) {
const filePath = path.join(modalsPath, file);
const modal = require(filePath);
client.modals.set(modal.name, modal);
}
const selectmenusPath = path.join(__dirname, 'interactions', 'selectmenus');
const selectmenusFiles = fs.readdirSync(selectmenusPath).filter(file => file.endsWith('.js'));
for (const file of selectmenusFiles) {
const filePath = path.join(selectmenusPath, file);
const selectmenu = require(filePath);
client.selectmenus.set(selectmenu.name, selectmenu);
}
client.login(token);
\ No newline at end of file
const { modal2 } = require('../../extra/apply_modals.js');
module.exports = {
name: 'apply_button1',
async execute(interaction) {
const data = interaction.client.applyInfo.get(interaction.user.id);
modal2.setTitle(`Apply for ${data.rank}!`);
await interaction.showModal(modal2);
// await interaction.editReply({ content: '', components: [] });
},
};
\ No newline at end of file
const { modal3 } = require('../../extra/apply_modals.js');
module.exports = {
name: 'apply_button2',
async execute(interaction) {
const data = interaction.client.applyInfo.get(interaction.user.id);
modal3.setTitle(`Apply for ${data.rank}!`);
await interaction.showModal(modal3);
// await interaction.editReply({ content: '', components: [] });
},
};
\ No newline at end of file
const { modal1 } = require('../../extra/apply_modals.js');
module.exports = {
name: 'apply_retry1',
async execute(interaction) {
const data = interaction.client.applyInfo.get(interaction.user.id);
modal1.setTitle(`Apply for ${data.rank}!`);
await interaction.showModal(modal1);
// await interaction.editReply({ content: '', components: [] });
},
};
\ No newline at end of file
const { modal2 } = require('../../extra/apply_modals.js');
module.exports = {
name: 'apply_retry2',
async execute(interaction) {
const data = interaction.client.applyInfo.get(interaction.user.id);
modal2.setTitle(`Apply for ${data.rank}!`);
await interaction.showModal(modal2);
// await interaction.editReply({ content: '', components: [] });
},
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment