Showing
2 changed files
with
34 additions
and
4 deletions
... | @@ -2,6 +2,31 @@ const { MessageActionRow, MessageButton, Interaction } = require('discord.js'); | ... | @@ -2,6 +2,31 @@ const { MessageActionRow, MessageButton, Interaction } = require('discord.js'); |
2 | 2 | ||
3 | // var trans = require('./translate'); | 3 | // var trans = require('./translate'); |
4 | 4 | ||
5 | +var disabled_var={ | ||
6 | + en:true, | ||
7 | + ko:false, | ||
8 | + jp:false | ||
9 | +}; | ||
10 | + | ||
11 | +function func_disabled_var(input_str){ | ||
12 | + if (input_str == "en"){ | ||
13 | + disabled_var.en=true; | ||
14 | + disabled_var.ko=false; | ||
15 | + disabled_var.jp=false; | ||
16 | + } | ||
17 | + else if (input_str == "ko"){ | ||
18 | + disabled_var.en=false; | ||
19 | + disabled_var.ko=true; | ||
20 | + disabled_var.jp=false; | ||
21 | + } | ||
22 | + else if (input_str == "jp"){ | ||
23 | + disabled_var.en=false; | ||
24 | + disabled_var.ko=false; | ||
25 | + disabled_var.jp=true; | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | + | ||
5 | exports.run = async (client, msg, args, prefix) => { | 30 | exports.run = async (client, msg, args, prefix) => { |
6 | 31 | ||
7 | const row = new MessageActionRow() | 32 | const row = new MessageActionRow() |
... | @@ -9,17 +34,20 @@ exports.run = async (client, msg, args, prefix) => { | ... | @@ -9,17 +34,20 @@ exports.run = async (client, msg, args, prefix) => { |
9 | new MessageButton() | 34 | new MessageButton() |
10 | .setCustomId('korean') | 35 | .setCustomId('korean') |
11 | .setLabel('한국어') | 36 | .setLabel('한국어') |
12 | - .setStyle('PRIMARY'), | 37 | + .setStyle('PRIMARY') |
38 | + .setDisabled(disabled_var.ko), | ||
13 | 39 | ||
14 | new MessageButton() | 40 | new MessageButton() |
15 | .setCustomId('japanese') | 41 | .setCustomId('japanese') |
16 | .setLabel('일본어') | 42 | .setLabel('일본어') |
17 | - .setStyle('PRIMARY'), | 43 | + .setStyle('PRIMARY') |
44 | + .setDisabled(disabled_var.jp), | ||
18 | 45 | ||
19 | new MessageButton() | 46 | new MessageButton() |
20 | .setCustomId('english') | 47 | .setCustomId('english') |
21 | .setLabel('영어') | 48 | .setLabel('영어') |
22 | - .setStyle('PRIMARY'), | 49 | + .setStyle('PRIMARY') |
50 | + .setDisabled(disabled_var.en), | ||
23 | ); //버튼 생성 | 51 | ); //버튼 생성 |
24 | 52 | ||
25 | await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] }); | 53 | await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] }); |
... | @@ -30,14 +58,17 @@ exports.run = async (client, msg, args, prefix) => { | ... | @@ -30,14 +58,17 @@ exports.run = async (client, msg, args, prefix) => { |
30 | 58 | ||
31 | if(interaction.customId === 'korean'){ | 59 | if(interaction.customId === 'korean'){ |
32 | global.trans_var ='ko'; | 60 | global.trans_var ='ko'; |
61 | + func_disabled_var('ko'); | ||
33 | } | 62 | } |
34 | 63 | ||
35 | else if(interaction.customId === 'japanese'){ | 64 | else if(interaction.customId === 'japanese'){ |
36 | global.trans_var ='jp'; | 65 | global.trans_var ='jp'; |
66 | + func_disabled_var('jp'); | ||
37 | } | 67 | } |
38 | 68 | ||
39 | else if(interaction.customId === 'english'){ | 69 | else if(interaction.customId === 'english'){ |
40 | global.trans_var ='en'; | 70 | global.trans_var ='en'; |
71 | + func_disabled_var('en'); | ||
41 | } | 72 | } |
42 | 73 | ||
43 | }); | 74 | }); | ... | ... |
-
Please register or login to post a comment