Skip to content

Commit

Permalink
feat: fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
gx1285 committed Jul 17, 2023
1 parent e79e22f commit ffc4cdc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/command/chatinput/rolepanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ export default {
const roles = [];

for (let index = 1; index <= 10; index++) {
const role = interaction.options.getRole(`role${index}`);
roles.push(role ? { id: role.id, name: role.name } : undefined);
const rawRole = interaction.options.getRole(`role${index}`);
const role = interaction.guild.roles.cache.get(rawRole.id);
const member = interaction.guild.members.cache.get(interaction.user.id);
if (role && member && member.roles.highest.comparePositionTo(role) <= 0)
return await interaction.error(
'実行者のロールよりも上位のロールを指定しています',
'指定したロールはあなたが持っているロールよりも上です。',
true,
);

roles.push(rawRole ? { id: rawRole.id, name: rawRole.name } : undefined);
}

await interaction.client.botData.rolePanel.set(id.toString(), roles);
Expand Down
19 changes: 12 additions & 7 deletions src/command/chatinput/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ChatInputCommandInteraction,
SlashCommandBuilder,
Colors,
PermissionFlagsBits,
} from 'discord.js';
export default {
command: new SlashCommandBuilder()
Expand All @@ -31,12 +32,21 @@ export default {
.setGuildOnly(),
ownersOnly: false,
modOnly: false,
permissions: false,
permissions: [PermissionFlagsBits.ManageRoles],

async execute(interaction: ChatInputCommandInteraction) {
const role = interaction.options.getRole('role');
const member = interaction.guild.members.cache.get(interaction.user.id);

if (role && member && member.roles.highest.comparePositionTo(role.id) <= 0)
return await interaction.error(
'実行者のロールよりも上位のロールを指定しています',
'指定したロールはあなたが持っているロールよりも上です。',
true,
);

switch (interaction.options.getString('type')) {
case '足し算認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand All @@ -55,7 +65,6 @@ export default {
break;
}
case '引き算認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand All @@ -74,7 +83,6 @@ export default {
break;
}
case '掛け算認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand All @@ -93,7 +101,6 @@ export default {
break;
}
case '割り算認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand All @@ -112,7 +119,6 @@ export default {
break;
}
case '1クリック認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand All @@ -131,7 +137,6 @@ export default {
break;
}
case '乱数認証': {
const role = interaction.options.getRole('role');
const message = await interaction.reply({
fetchReply: true,
embeds: [
Expand Down

0 comments on commit ffc4cdc

Please sign in to comment.