노영우

button disabled

...@@ -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 });
......
...@@ -65,6 +65,5 @@ exports.config = { ...@@ -65,6 +65,5 @@ exports.config = {
65 65
66 /*고칠 것 66 /*고칠 것
67 1. 상호작용 실패 알림 뜨는거 67 1. 상호작용 실패 알림 뜨는거
68 -2. !번역, 영어상태에서 영어 번역하면 에러 떠서 멈춰버림
69 3. 꾸미기(?) 68 3. 꾸미기(?)
70 */ 69 */
...\ No newline at end of file ...\ No newline at end of file
......