commit
43633dfd60
19 changed files with 430 additions and 80 deletions
10
.vscode/extensions.json
vendored
10
.vscode/extensions.json
vendored
|
@ -32,7 +32,15 @@
|
||||||
"ms-vscode.js-debug-companion",
|
"ms-vscode.js-debug-companion",
|
||||||
"ms-vscode.references-view",
|
"ms-vscode.references-view",
|
||||||
"ms-vscode.vscode-js-profile-table",
|
"ms-vscode.vscode-js-profile-table",
|
||||||
"pflannery.vscode-versionlens"
|
"pflannery.vscode-versionlens",
|
||||||
|
"adpyke.codesnap",
|
||||||
|
"Anan.devdocstab",
|
||||||
|
"axosoft.gitkraken-glo",
|
||||||
|
"Gruntfuggly.todo-tree",
|
||||||
|
"kiteco.kite",
|
||||||
|
"lkytal.pomodoro",
|
||||||
|
"wayou.vscode-todo-highlight",
|
||||||
|
"johnpapa.vscode-peacock"
|
||||||
],
|
],
|
||||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||||
"unwantedRecommendations": []
|
"unwantedRecommendations": []
|
||||||
|
|
37
.vscode/settings.json
vendored
37
.vscode/settings.json
vendored
|
@ -1,26 +1,8 @@
|
||||||
{
|
{
|
||||||
"editor.wordWrapColumn": 100,
|
"editor.wordWrapColumn": 100,
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
// "workbench.colorCustomizations": {
|
|
||||||
// "titleBar.activeBackground": "#336699",
|
|
||||||
// "titleBar.inactiveBackground": "#33669999",
|
|
||||||
// "titleBar.activeForeground": "#e7e7e7",
|
|
||||||
// "titleBar.inactiveForeground": "#e7e7e799",
|
|
||||||
// "statusBarItem.hoverBackground": "#407fbf",
|
|
||||||
// "activityBar.activeBackground": "#407fbf",
|
|
||||||
// "activityBar.activeBorder": "#77284f",
|
|
||||||
// "activityBar.background": "#407fbf",
|
|
||||||
// "activityBar.foreground": "#e7e7e7",
|
|
||||||
// "activityBar.inactiveForeground": "#e7e7e799",
|
|
||||||
// "activityBarBadge.background": "#77284f",
|
|
||||||
// "activityBarBadge.foreground": "#e7e7e7",
|
|
||||||
// "sash.hoverBorder": "#407fbf",
|
|
||||||
// "statusBarItem.remoteBackground": "#336699",
|
|
||||||
// "statusBarItem.remoteForeground": "#e7e7e7"
|
|
||||||
// },
|
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"javascript.format.enable": false,
|
"javascript.format.enable": false,
|
||||||
"eslint.autoFixOnSave": true,
|
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
"prettier.endOfLine": "lf",
|
"prettier.endOfLine": "lf",
|
||||||
"prettier.singleQuote": true,
|
"prettier.singleQuote": true,
|
||||||
|
@ -29,23 +11,6 @@
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": true
|
||||||
},
|
},
|
||||||
"workbench.colorCustomizations": {
|
|
||||||
"activityBar.activeBackground": "#407fbf",
|
|
||||||
"activityBar.activeBorder": "#77284f",
|
|
||||||
"activityBar.background": "#407fbf",
|
|
||||||
"activityBar.foreground": "#e7e7e7",
|
|
||||||
"activityBar.inactiveForeground": "#e7e7e799",
|
|
||||||
"activityBarBadge.background": "#77284f",
|
|
||||||
"activityBarBadge.foreground": "#e7e7e7",
|
|
||||||
"sash.hoverBorder": "#407fbf",
|
|
||||||
"statusBarItem.hoverBackground": "#407fbf",
|
|
||||||
"statusBarItem.remoteBackground": "#336699",
|
|
||||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
|
||||||
"titleBar.activeBackground": "#336699",
|
|
||||||
"titleBar.activeForeground": "#e7e7e7",
|
|
||||||
"titleBar.inactiveBackground": "#33669999",
|
|
||||||
"titleBar.inactiveForeground": "#e7e7e799"
|
|
||||||
},
|
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Controlpanel",
|
"Controlpanel",
|
||||||
"discordjs",
|
"discordjs",
|
||||||
|
@ -55,5 +20,7 @@
|
||||||
"upsert",
|
"upsert",
|
||||||
"uuidv"
|
"uuidv"
|
||||||
],
|
],
|
||||||
|
"editor.fontFamily": "Cascadia Code",
|
||||||
|
"editor.fontLigatures": true,
|
||||||
"git.enableCommitSigning": true
|
"git.enableCommitSigning": true
|
||||||
}
|
}
|
||||||
|
|
89
src/commands/admin/counter/addons/add.js
Normal file
89
src/commands/admin/counter/addons/add.js
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
const { Permissions } = require('discord.js');
|
||||||
|
const config = require('../../../../../config.json');
|
||||||
|
const logger = require('../../../../handlers/logger');
|
||||||
|
|
||||||
|
// Database models
|
||||||
|
const { counters } = require('../../../../helpers/database/models');
|
||||||
|
|
||||||
|
module.exports = async (interaction) => {
|
||||||
|
// Destructure member
|
||||||
|
const { member } = interaction;
|
||||||
|
|
||||||
|
// Check permission
|
||||||
|
if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin',
|
||||||
|
color: config.colors.error,
|
||||||
|
description: 'You do not have permission to manage this!',
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get options
|
||||||
|
const channel = await interaction.options.getChannel('channel');
|
||||||
|
const word = await interaction.options.getString('word');
|
||||||
|
const start = await interaction.options.getNumber('start');
|
||||||
|
|
||||||
|
if (channel.type !== 'GUILD_TEXT') {
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin - Counter',
|
||||||
|
description: `That channel is not supported, it needs to be a text channel.`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
color: config.colors.error,
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return await interaction.editReply({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
|
||||||
|
const counterExist = await counters.findOne({
|
||||||
|
guildId: member.guild.id,
|
||||||
|
channelId: channel.id,
|
||||||
|
word,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!counterExist) {
|
||||||
|
await counters.create({
|
||||||
|
guildId: member.guild.id,
|
||||||
|
channelId: channel.id,
|
||||||
|
word,
|
||||||
|
counter: start || 0,
|
||||||
|
});
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin - Counter',
|
||||||
|
description: `${channel} is now counting when hearing word ${word} and it starts at number ${
|
||||||
|
start || 0
|
||||||
|
}.`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
color: config.colors.success,
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send debug message
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${member.guild.id} User: ${member.id} added ${channel.id} as a counter using word "${word}" for counting.`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return await interaction.editReply({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin - Counter',
|
||||||
|
description: `${channel} is already a counting channel.`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
color: config.colors.error,
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return await interaction.editReply({ embeds: [embed] });
|
||||||
|
};
|
4
src/commands/admin/counter/addons/index.js
Normal file
4
src/commands/admin/counter/addons/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
const add = require('./add');
|
||||||
|
const remove = require('./remove');
|
||||||
|
|
||||||
|
module.exports = { add, remove };
|
40
src/commands/admin/counter/addons/remove.js
Normal file
40
src/commands/admin/counter/addons/remove.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
const { Permissions } = require('discord.js');
|
||||||
|
const config = require('../../../../../config.json');
|
||||||
|
const logger = require('../../../../handlers/logger');
|
||||||
|
|
||||||
|
// Database models
|
||||||
|
const { counters } = require('../../../../helpers/database/models');
|
||||||
|
|
||||||
|
module.exports = async (interaction) => {
|
||||||
|
// Destructure member
|
||||||
|
const { member } = interaction;
|
||||||
|
|
||||||
|
// Check permission
|
||||||
|
if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin',
|
||||||
|
color: config.colors.error,
|
||||||
|
description: 'You do not have permission to manage this!',
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get options
|
||||||
|
const channel = await interaction.options.getChannel('channel');
|
||||||
|
|
||||||
|
await counters
|
||||||
|
.deleteOne({ guildId: member.guild.id, channelId: channel.id })
|
||||||
|
.then(async () => {
|
||||||
|
interaction.editReply({ content: 'Removed' });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send debug message
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${member.guild.id} User: ${member.id} executed remove counter.`
|
||||||
|
);
|
||||||
|
};
|
44
src/commands/admin/counter/index.js
Normal file
44
src/commands/admin/counter/index.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
const { Permissions } = require('discord.js');
|
||||||
|
const config = require('../../../../config.json');
|
||||||
|
const logger = require('../../../handlers/logger');
|
||||||
|
|
||||||
|
const { add, remove } = require('./addons');
|
||||||
|
|
||||||
|
module.exports = async (interaction) => {
|
||||||
|
// Destructure member
|
||||||
|
const { member } = interaction;
|
||||||
|
|
||||||
|
// Check permission
|
||||||
|
if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Admin',
|
||||||
|
color: config.colors.error,
|
||||||
|
description: 'You do not have permission to manage this!',
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
await interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// If subcommand is give
|
||||||
|
if (interaction.options.getSubcommand() === 'add') {
|
||||||
|
// Execute give addon
|
||||||
|
await add(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If subcommand is take
|
||||||
|
else if (interaction.options.getSubcommand() === 'remove') {
|
||||||
|
// Execute take addon
|
||||||
|
await remove(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send debug message
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${member.guild.id} User: ${member.id} executed /${
|
||||||
|
interaction.commandName
|
||||||
|
} ${interaction.options.getSubcommandGroup()} ${interaction.options.getSubcommand()}`
|
||||||
|
);
|
||||||
|
};
|
|
@ -1,6 +1,7 @@
|
||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
|
||||||
const credits = require('./credits');
|
const credits = require('./credits');
|
||||||
|
const counter = require('./counter');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -84,6 +85,42 @@ module.exports = {
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
.addSubcommandGroup((group) =>
|
||||||
|
group
|
||||||
|
.setName('counter')
|
||||||
|
.setDescription('Manage counters.')
|
||||||
|
.addSubcommand((command) =>
|
||||||
|
command
|
||||||
|
.setName('add')
|
||||||
|
.setDescription('Add a counter')
|
||||||
|
.addChannelOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('channel')
|
||||||
|
.setDescription('The counter channel.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('word')
|
||||||
|
.setDescription('The counter word.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option.setName('start').setDescription('Start at number X.')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addSubcommand((command) =>
|
||||||
|
command
|
||||||
|
.setName('remove')
|
||||||
|
.setDescription('Remove a counter')
|
||||||
|
.addChannelOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('channel')
|
||||||
|
.setDescription('The counter channel.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
// If subcommand group is credits
|
// If subcommand group is credits
|
||||||
|
@ -91,5 +128,11 @@ module.exports = {
|
||||||
// Execute credits group
|
// Execute credits group
|
||||||
await credits(interaction);
|
await credits(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If subcommand group is credits
|
||||||
|
else if (interaction.options.getSubcommandGroup() === 'counter') {
|
||||||
|
// Execute credits group
|
||||||
|
await counter(interaction);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
48
src/commands/counter/addons/view.js
Normal file
48
src/commands/counter/addons/view.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const config = require('../../../../config.json');
|
||||||
|
const logger = require('../../../handlers/logger');
|
||||||
|
|
||||||
|
const { counters } = require('../../../helpers/database/models');
|
||||||
|
|
||||||
|
module.exports = async (interaction) => {
|
||||||
|
try {
|
||||||
|
// Destructure member
|
||||||
|
const { member } = await interaction;
|
||||||
|
|
||||||
|
// Get options
|
||||||
|
const channel = await interaction.options.getChannel('channel');
|
||||||
|
|
||||||
|
const counter = await counters.findOne({
|
||||||
|
guildId: member.guild.id,
|
||||||
|
channelId: channel.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!counter) {
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Counter - View',
|
||||||
|
description: `${channel} is not a counting channel.`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
color: config.colors.error,
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return await interaction.editReply({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create embed object
|
||||||
|
const embed = {
|
||||||
|
title: 'Counter - View',
|
||||||
|
color: config.colors.success,
|
||||||
|
description: `${channel} is currently at number ${counter.counter}.`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send interaction reply
|
||||||
|
return await interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
|
} catch (e) {
|
||||||
|
// Send debug message
|
||||||
|
await logger.error(e);
|
||||||
|
}
|
||||||
|
};
|
26
src/commands/counter/index.js
Normal file
26
src/commands/counter/index.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
|
||||||
|
const view = require('./addons/view');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('counter')
|
||||||
|
.setDescription('Manage counters.')
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName('view')
|
||||||
|
.setDescription('View a counter.')
|
||||||
|
.addChannelOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('channel')
|
||||||
|
.setDescription('The counter channel you want to view')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
async execute(interaction) {
|
||||||
|
// If subcommand is view
|
||||||
|
if (interaction.options.getSubcommand() === 'view') {
|
||||||
|
// Execute view addon
|
||||||
|
await view(interaction);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -5,6 +5,7 @@ const {
|
||||||
guilds,
|
guilds,
|
||||||
experiences,
|
experiences,
|
||||||
credits,
|
credits,
|
||||||
|
counters,
|
||||||
timeouts,
|
timeouts,
|
||||||
} = require('../helpers/database/models');
|
} = require('../helpers/database/models');
|
||||||
|
|
||||||
|
@ -17,6 +18,30 @@ module.exports = {
|
||||||
// If message author is bot
|
// If message author is bot
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
|
||||||
|
// Get counter object
|
||||||
|
const counter = await counters.findOne({
|
||||||
|
guildId: message.guild.id,
|
||||||
|
channelId: message.channel.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
// If counter for the message channel
|
||||||
|
if (counter) {
|
||||||
|
// If message content is not strictly the same as counter word
|
||||||
|
if (message.content !== counter.word) {
|
||||||
|
// Delete the message
|
||||||
|
await message.delete();
|
||||||
|
} else {
|
||||||
|
// Add 1 to the counter object
|
||||||
|
await counters.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
guildId: message.guild.id,
|
||||||
|
channelId: message.channel.id,
|
||||||
|
},
|
||||||
|
{ $inc: { counter: 1 } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create user if not already created
|
// Create user if not already created
|
||||||
await users.findOne(
|
await users.findOne(
|
||||||
{ userId: message.author.id },
|
{ userId: message.author.id },
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
const logger = require('../handlers/logger');
|
const logger = require('../handlers/logger');
|
||||||
|
|
||||||
|
const { database, deployCommands } = require('../helpers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'ready',
|
name: 'ready',
|
||||||
once: true,
|
once: true,
|
||||||
|
@ -14,5 +16,7 @@ module.exports = {
|
||||||
],
|
],
|
||||||
status: 'online',
|
status: 'online',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await deployCommands();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
13
src/handlers/commands.js
Normal file
13
src/handlers/commands.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
const fs = require('fs'); // fs
|
||||||
|
const { Collection } = require('discord.js'); // discord.js
|
||||||
|
|
||||||
|
module.exports = async (client) => {
|
||||||
|
client.commands = new Collection();
|
||||||
|
const commandFiles = fs.readdirSync('./src/commands');
|
||||||
|
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||||
|
const command = require(`../commands/${file}`);
|
||||||
|
client.commands.set(command.data.name, command);
|
||||||
|
}
|
||||||
|
};
|
16
src/handlers/events.js
Normal file
16
src/handlers/events.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
const fs = require('fs'); // fs
|
||||||
|
|
||||||
|
module.exports = async (client) => {
|
||||||
|
const eventFiles = fs
|
||||||
|
.readdirSync('./src/events')
|
||||||
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of eventFiles) {
|
||||||
|
const event = require(`../events/${file}`);
|
||||||
|
if (event.once) {
|
||||||
|
client.once(event.name, (...args) => event.execute(...args));
|
||||||
|
} else {
|
||||||
|
client.on(event.name, (...args) => event.execute(...args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
5
src/handlers/index.js
Normal file
5
src/handlers/index.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
const events = require('./events');
|
||||||
|
const commands = require('./commands');
|
||||||
|
const locale = require('./locale');
|
||||||
|
|
||||||
|
module.exports = { events, commands, locale };
|
34
src/helpers/database/models/counterSchema.js
Normal file
34
src/helpers/database/models/counterSchema.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
|
const counterSchema = new mongoose.Schema(
|
||||||
|
{
|
||||||
|
guildId: {
|
||||||
|
type: mongoose.SchemaTypes.Decimal128,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
channelId: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
required: true,
|
||||||
|
unique: true,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
word: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
counter: {
|
||||||
|
type: mongoose.SchemaTypes.Number,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports = mongoose.model('counter', counterSchema);
|
|
@ -4,6 +4,7 @@ const users = require('./userSchema');
|
||||||
const guilds = require('./guildSchema');
|
const guilds = require('./guildSchema');
|
||||||
const apis = require('./apiSchema');
|
const apis = require('./apiSchema');
|
||||||
const timeouts = require('./timeoutSchema');
|
const timeouts = require('./timeoutSchema');
|
||||||
|
const counters = require('./counterSchema');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
credits,
|
credits,
|
||||||
|
@ -12,4 +13,5 @@ module.exports = {
|
||||||
guilds,
|
guilds,
|
||||||
apis,
|
apis,
|
||||||
timeouts,
|
timeouts,
|
||||||
|
counters,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
/* eslint-disable no-restricted-syntax */
|
const config = require('../../config.json');
|
||||||
const config = require('../config.json');
|
const logger = require('../handlers/logger');
|
||||||
|
const fs = require('fs');
|
||||||
const logger = require('./handlers/logger');
|
const { REST } = require('@discordjs/rest');
|
||||||
|
const { Routes } = require('discord-api-types/v9');
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
// eslint-disable-next-line global-require
|
|
||||||
const fs = require('fs');
|
|
||||||
// eslint-disable-next-line global-require
|
|
||||||
const { REST } = require('@discordjs/rest');
|
|
||||||
// eslint-disable-next-line global-require
|
|
||||||
const { Routes } = require('discord-api-types/v9');
|
|
||||||
|
|
||||||
const commands = [];
|
const commands = [];
|
||||||
const commandFiles = fs.readdirSync('./src/commands');
|
const commandFiles = fs.readdirSync('./src/commands');
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||||
const command = require(`./commands/${file}`);
|
const command = require(`../commands/${file}`);
|
||||||
commands.push(command.data.toJSON());
|
commands.push(command.data.toJSON());
|
||||||
}
|
}
|
||||||
|
|
4
src/helpers/index.js
Normal file
4
src/helpers/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
const database = require('./database');
|
||||||
|
const deployCommands = require('./deployCommands');
|
||||||
|
|
||||||
|
module.exports = { database, deployCommands };
|
48
src/index.js
48
src/index.js
|
@ -1,37 +1,21 @@
|
||||||
const fs = require('fs');
|
// Dependencies
|
||||||
const { Client, Collection, Intents } = require('discord.js');
|
const { Client, Intents } = require('discord.js'); // discord.js
|
||||||
|
|
||||||
require('./deploy-commands')();
|
const { database } = require('./helpers'); // helpers
|
||||||
require('./helpers/database')();
|
const { events, commands, locale } = require('./handlers'); // handlers
|
||||||
require('./handlers/locale')();
|
|
||||||
|
|
||||||
const config = require('../config.json');
|
const config = require('../config.json'); // config.json
|
||||||
|
|
||||||
const client = new Client({
|
(async () => {
|
||||||
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
// Initialize discord.js client
|
||||||
});
|
const client = new Client({
|
||||||
|
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
||||||
|
});
|
||||||
|
|
||||||
const eventFiles = fs
|
await database();
|
||||||
.readdirSync('./src/events')
|
await locale();
|
||||||
.filter((file) => file.endsWith('.js'));
|
await events(client);
|
||||||
|
await commands(client);
|
||||||
|
|
||||||
client.commands = new Collection();
|
await client.login(config.bot.token);
|
||||||
const commandFiles = fs.readdirSync('./src/commands');
|
})();
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
|
||||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
||||||
const command = require(`./commands/${file}`);
|
|
||||||
client.commands.set(command.data.name, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const file of eventFiles) {
|
|
||||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
||||||
const event = require(`./events/${file}`);
|
|
||||||
if (event.once) {
|
|
||||||
client.once(event.name, (...args) => event.execute(...args));
|
|
||||||
} else {
|
|
||||||
client.on(event.name, (...args) => event.execute(...args));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client.login(config.bot.token);
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue