Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
2.8 kB
9
Indexable
Never
if(input.startsWith(">redeem")){
                 let data = input.split(" ");
                 if(data.length < 4){
                     api.sendMessage("❌Invalid Use Of Command!\n💡Usage: >redeem id vcode code", event.threadID);
                 } else {
                     try{
                         let gameid = data[1];
                         let vcode = data[2];
                         let code = event.messageReply.body;
                         function redeem(gameid, vcode, code){
                             (async () => {
                                 try {
                                     const response = await axios.post('https://api.mobilelegends.com/mlweb/sendCdk',{"redeemCode": code,"roleId": gameid ,"vCode": vcode,"language":"en"});                       
                                     const msgs = ('{"-20023": "Invalid Game ID","-20027":"Request too Frequent!...","-20010":"Invalid Verification Code!","0":"Redeemed Successfully!","1401":"redeem in specified zone","1402":"This CDKey does not exist","1403":"CDKey expired","1404":"Incorrect format of CDKey","1405":"This CDKey has been redeemed.","1406":"Bound Account CDKey. Incorrect account.","1407":"Exceeds exchange amount limit.","1408":"Can only redeem in specified zone.","1409":"Restriction Requirement Configuration Error","1410":"This CDKey is being redeemed by many players. The Server is processing... Please try again later.","1411":"It\'s not exchange time, please wait.","1412":"Limit reached for number of people exchanging.","1413":"You are not a new user","1414":"You haven\'t purchased yet","1415":"Your level is too high","1416":"You can not redeem the CDKey through your channel","1036":"The amount limitation of CDKey redeemption"}');
                                     let responses = JSON.parse(msgs);
                                     let resp = response.data.code;
                                     let respcode = resp.toString();
                                     let msg = responses[respcode];
                                     let stat = response.data.status;
                                     api.sendMessage("💠Api Response💠\n🔰Status: " + stat + "\n📧Message: " + msg + "", event.threadID);
                                 } catch (error) {
                                     console.log(error.message);
                                 }
                               })();
                         }
                         api.sendMessage("🔁Trying to Redeem...("+code+")", event.threadID);
                         redeem(gameid, vcode, code);
                     } catch(err){
                         api.sendMessage("Error: " + err.message, event.threadID);
                     }
                 }