Compare commits

...

2 Commits

Author SHA1 Message Date
baz 9bc73d2630 Update .env variable names 2023-12-30 00:50:23 +00:00
baz 87fa9e762d Delete redundant commands 2023-12-30 00:49:50 +00:00
9 changed files with 31 additions and 87 deletions

View File

@ -1,6 +1,6 @@
clientId=
guildId=
token=
discordClientId=
discordGuildId=
discordToken=
igdbClientId=
igdbClientSecret=
igdbAccessToken=

View File

@ -1,14 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('Get the avatar URL of the selected user, or your own avatar.')
.addUserOption(option => option.setName('user').setDescription('The user\'s avatar to show')),
async execute(interaction) {
const user = interaction.options.getUser('user');
if (user) return interaction.reply(`${user.username}'s avatar: ${user.displayAvatarURL()}`);
return interaction.reply(`Your avatar: ${interaction.user.displayAvatarURL()}`);
},
};

View File

@ -1,11 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};

View File

@ -1,32 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('reload')
.setDescription('Reload a command.')
.addStringOption(option =>
option.setName('command')
.setDescription('The command to reload.')
.setRequired(true)),
async execute(interaction) {
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);
if (!command) {
return interaction.reply(`There is no command with name \`${commandName}\`!`);
}
delete require.cache[require.resolve(`./${command.data.name}.js`)];
try {
interaction.client.commands.delete(command.data.name);
const newCommand = require(`./${command.data.name}.js`);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
} catch (error) {
console.error(error);
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
}
},
};

View File

@ -1,10 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('server')
.setDescription('Provides information about the server.'),
async execute(interaction) {
await interaction.reply(`This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
},
};

View File

@ -1,14 +0,0 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// interaction.user is the object representing the user who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
},
};

View File

@ -19,4 +19,29 @@ BeatenGames.belongsTo(Users);
Games.hasMany(BeatenGames);
BeatenGames.belongsTo(Games);
Reflect.defineProperty(Users.prototype, 'addUser', {
value: async function addUser(userData) {
const user = await Users.findOne({
where: { user_id: userData.id },
});
if (!user) {
return Users.create({ user_id: userData.discord_id, username: userData.username });
}
},
});
Reflect.defineProperty(Users.prototype, 'getUser', {
value: function getUser(userData) {
return Users.findAll({
where: { user_id: userData.discord_id },
});
},
});
sequelize.sync({ alter: true })
.catch((err) => {
console.log(err);
});
module.exports = { Users, Games, BeatenGames };

View File

@ -27,7 +27,7 @@ for (const folder of commandFolders) {
}
// Construct and prepare an instance of the REST module
const rest = new REST().setToken(process.env.token);
const rest = new REST().setToken(process.env.discordToken);
// and deploy your commands!
(async () => {
@ -36,7 +36,7 @@ const rest = new REST().setToken(process.env.token);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(process.env.clientId, process.env.guildId),
Routes.applicationGuildCommands(process.env.discordClientId, process.env.discordGuildId),
{ body: commands },
);

View File

@ -48,7 +48,7 @@ for (const file of eventFiles) {
}
}
client.login(process.env.token);
client.login(process.env.discordToken);
client.once(Events.ClientReady, () => {
console.log(`Logged in as ${client.user.tag}!`);