Compare commits

..

No commits in common. "9bc73d263035097169615c9448323dd9cff353cc" and "9d1c6ecfb62cab6f8eb3a986908167ddd103caf0" have entirely different histories.

9 changed files with 87 additions and 31 deletions

View File

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

View File

@ -0,0 +1,14 @@
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()}`);
},
};

11
commands/testing/ping.js Normal file
View File

@ -0,0 +1,11 @@
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

@ -0,0 +1,32 @@
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

@ -0,0 +1,10 @@
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.`);
},
};

14
commands/testing/user.js Normal file
View File

@ -0,0 +1,14 @@
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,29 +19,4 @@ 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.discordToken);
const rest = new REST().setToken(process.env.token);
// and deploy your commands!
(async () => {
@ -36,7 +36,7 @@ const rest = new REST().setToken(process.env.discordToken);
// 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.discordClientId, process.env.discordGuildId),
Routes.applicationGuildCommands(process.env.clientId, process.env.guildId),
{ body: commands },
);

View File

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