Skip to content

Commit

Permalink
Merge pull request #134 from Project-Coda/autoroles
Browse files Browse the repository at this point in the history
Fix autorole bug
  • Loading branch information
ikifar2012 authored Mar 16, 2023
2 parents 7e5c579 + 9baf236 commit 2347f0f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 56 deletions.
94 changes: 42 additions & 52 deletions commands/autorole.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const env = require('../env.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('autorole')
.setDescription('confiugure autoroles')
.setDescription('confiugure auto roles')
.addSubcommand(subcommand =>
subcommand
.setName('add')
Expand All @@ -27,7 +27,7 @@ module.exports = {
.addSubcommand(subcommand =>
subcommand
.setName('list')
.setDescription('lists all autoroles'),
.setDescription('lists all auto roles'),
),
async execute(interaction) {
try {
Expand All @@ -53,61 +53,51 @@ module.exports = {
}
catch (error) {
console.log(error);

}
const subcommand = await interaction.options.getSubcommand();
if (subcommand === 'add') {
const role = await interaction.options.getRole('role');
await autorole.add(role.id);
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Autorole Added',
description: `Added ${role} to the autorole list.`,
color: 0x2ecc71,
})],
});
embedcreator.sendError(error);
}
if (subcommand === 'remove') {
const role = await interaction.options.getRole('role');
await autorole.remove(role.id);
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Autorole Removed',
description: `Removed ${role} from the autorole list.`,
color: 0x2ecc71,
})],
});
}
const subcommand = await interaction.options.getSubcommand();
if (subcommand === 'add') {
const role = await interaction.options.getRole('role');
await autorole.add(role.id);
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Auto Role Added',
description: `Added ${role} to the autorole list.`,
color: 0x2ecc71,
})],
});
}
if (subcommand === 'remove') {
const role = await interaction.options.getRole('role');
await autorole.remove(role.id);
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Auto Role Removed',
description: `Removed ${role} from the autorole list.`,
color: 0x2ecc71,
})],
});

}
if (subcommand === 'list') {
const roles = await autorole.list();
const roleNames = [];
for (const role of roles) {
roleNames.push(`<@&${role}>`);
}
if (subcommand === 'list') {
const roles = await autorole.list();
const roleNames = [];
for (const role of roles) {
roleNames.push(`<@&${role}>`);
}
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Autoroles',
description: roleNames.join(', '),
color: 0x2ecc71,
})],
});
}
return interaction.reply({
embeds: [embedcreator.setembed({
title: 'Auto Roles',
description: roleNames.join(', '),
color: 0x2ecc71,
})],
});
}
}
catch (err) {
console.log(err);
await interaction.editReply(
{
embeds: [ embedcreator.setembed(
{
title: 'Error',
description: err,
color: 0xe74c3c,
},
)],
},
);
catch (error) {
console.error(error);
embedcreator.sendError(error);
}
},
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coda-utilities",
"version": "2.6.0",
"version": "2.6.1",
"description": "A general utilities bot for Coda",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion utilities/autorole.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function assignRoles(member) {
embedcreator.sendError(error);
}
}
embedcreator.log(`Assigned roles to ${member.user.tag}`);
return embedcreator.log(`Assigned roles to ${member.user.tag}`);
}
catch (error) {
console.error(error);
Expand Down

0 comments on commit 2347f0f

Please sign in to comment.