노영우

button disabled

......@@ -2,6 +2,31 @@ const { MessageActionRow, MessageButton, Interaction } = require('discord.js');
// var trans = require('./translate');
var disabled_var={
en:true,
ko:false,
jp:false
};
function func_disabled_var(input_str){
if (input_str == "en"){
disabled_var.en=true;
disabled_var.ko=false;
disabled_var.jp=false;
}
else if (input_str == "ko"){
disabled_var.en=false;
disabled_var.ko=true;
disabled_var.jp=false;
}
else if (input_str == "jp"){
disabled_var.en=false;
disabled_var.ko=false;
disabled_var.jp=true;
}
}
exports.run = async (client, msg, args, prefix) => {
const row = new MessageActionRow()
......@@ -9,17 +34,20 @@ exports.run = async (client, msg, args, prefix) => {
new MessageButton()
.setCustomId('korean')
.setLabel('한국어')
.setStyle('PRIMARY'),
.setStyle('PRIMARY')
.setDisabled(disabled_var.ko),
new MessageButton()
.setCustomId('japanese')
.setLabel('일본어')
.setStyle('PRIMARY'),
.setStyle('PRIMARY')
.setDisabled(disabled_var.jp),
new MessageButton()
.setCustomId('english')
.setLabel('영어')
.setStyle('PRIMARY'),
.setStyle('PRIMARY')
.setDisabled(disabled_var.en),
); //버튼 생성
await msg.reply({ content: '번역할 나라를 골라주세요.', components: [row] });
......@@ -30,14 +58,17 @@ exports.run = async (client, msg, args, prefix) => {
if(interaction.customId === 'korean'){
global.trans_var ='ko';
func_disabled_var('ko');
}
else if(interaction.customId === 'japanese'){
global.trans_var ='jp';
func_disabled_var('jp');
}
else if(interaction.customId === 'english'){
global.trans_var ='en';
func_disabled_var('en');
}
});
......
......@@ -65,6 +65,5 @@ exports.config = {
/*고칠 것
1. 상호작용 실패 알림 뜨는거
2. !번역, 영어상태에서 영어 번역하면 에러 떠서 멈춰버림
3. 꾸미기(?)
*/
\ No newline at end of file
......