Jump to content
Sign in to follow this  
Kalfka

[11/28/2021] Custom SPK Discord Bot

Recommended Posts

Hey SPK,

This post relates to a side project that I've been working on for the SPK Raids Fam Discord (server link below). We are a community for new players and veterans alike! So please consider joining if you are not part of the community already 🙂

I've been having trouble with my command handler in my main client.js file, specifically its ability to .execute specific commands that I've written. 

 

// ------- loadouts tob ------- //

        if (command === 'loadout' && args[0] === 'tob' && args[1] <= 500) {
                 client.commands.get('tobtemplate').execute(message, args, Discord);
     
        } else if (command === 'loadout' && args[0] === 'tob' && args[1] <= 1000) {       
                 client.commands.get('tobloadout-1').execute(message, args, Discord);

        } else if (command === 'loadout' && args[0] === 'tob' && args[1] <= 1500) {       
                 client.commands.get('tobloadout-2').execute(message, args, Discord);
          
// ------- loadouts cox ------- //

        } else if (command === 'loadout' && args[0] === 'cox' && args[1] <= 500) {       
                 client.commands.get('coxtemplate').execute(message, args, Discord);

        } else if (command === 'loadout' && args[0] === 'cox' && args[1] <= 1000) {       
                 client.commands.get('coxloadout-1').execute(message, args, Discord);
                 
        } else if (command === 'loadout' && args[0] === 'cox' && args[1] <= 1500) {       
                 client.commands.get('coxloadout-2').execute(message, args, Discord);

// ------- loadouts else ------- //

        } else if (command === 'loadout'&& !args.length) {
                 message.channel.send('`Please specify a game mode and price!`');

        } else if (command === 'loadout'&& args[0] === 'cox' && !args[1]) {
                 message.channel.send('`Please specify a price!`');

        } else if (command === 'loadout'&& args[0] === 'tob' && !args[1]) {
                 message.channel.send('`Please specify a price!`');

 

The logic is pretty basic, but let me explain in English how it is set up to work. 

  1. If you input a command: ?loadout tob 200
  2. It should activate client.commands.get('tobtemplate').execute(message, args, Discord);

(both 'tobtemplate.js' and 'tobloadout-1.js' are identical embeds)

  1. If you input a command: ?loadout tob 555
  2. It should activate client.commands.get('tobloadout-1').execute(message, args, Discord);

The only difference between the two inputs is which command is called (tobtemplate.js or tobloadout-1.js). Both tobtemplate.js and tobloadout-1.js are identical files besides their name, they are in the same location and everything, but only one of them works (tobtemplate). The command handler works just fine if each command is changed to either 'coxtemplate' or 'tobtemplate', so I believe the problem lies within the command .js files themselves... Here is what they look like inside:

 

module.exports = {
    name:'tobloadout-1',
    description: "Embeds!",
    execute(message, args, Discord) {
        const tob0 = new Discord.MessageEmbed()
        .setColor('#b92124')
        .setTitle('Theatre of Blood')
        .setDescription('Loadout ID: 0')
        //.setAuthor('Theatre of Blood', 'https://media.discordapp.net/attachments/753805578362552462/906354324467224617/output-onlinegiftools.gif')
        .setImage('https://media.discordapp.net/attachments/906401044160983040/908615355126140978/tob_500.png')
        .setThumbnail('https://media.discordapp.net/attachments/906401044160983040/908590466591764531/verzik.gif')
        .addFields(
            {name: 'tekton_pet', value: '500', inline: true},
            {name: 'slayer_helm_(i)', value: '35-70', inline: true}, 
            {name: 'chaos_cloak', value: '10-50', inline: true}, 
            {name: 'devout_boots', value: '50-100', inline: true}, 
            {name: 'serachnis_cudgel', value: '35-150', inline: true}, 
            {name: 'toxic_blowpipe', value: '30-75', inline: true}, 
            {name: 'toxic_staff_of_the_dead', value: '10-50', inline: true}, 
            {name: 'goliath_gloves', value: '22-35', inline: true}, 
            {name: 'ancient_wyvern_shield', value: 'price', inline: true}, 
            {name: 'vesta\'s_chainbody', value: 'price', inline: true}, 
            {name: 'vesta\'s_plateskirt', value: 'price', inline: true}, 
            {name: 'zuriel\'s_ropbe_top', value: 'price', inline: true}, 
            {name: 'zuriel\'s_robe_bottom', value: 'price', inline: true}, 
            {name: 'morrigan\'s_leather_body', value: 'price', inline: true}, 
            {name: 'morrigan\'s_leather_chaps', value: 'price', inline: true}, 
            {name: 'rune_pouch', value: '10-45', inline: true}, 
            {name: 'statius\'s_warhammer', value: 'price', inline: true}
 
        )
        .setFooter('Next upgrade: 500 bags.');

        message.channel.send({ embeds: [tob0] }); 
    }
}

 

All commands 'tobtemplate', 'tobloadout-1', 'tobloadout-2', 'coxtemplate', 'coxloadout-1', and 'coxloadout-2' are identical and have the above contents. They are all located in the same commands folder within my discord bot, so there is some higher level of confusion that I am not understanding... It should work, but instead I get the error code below:

 

error.png

 

If you have any ideas of what could be wrong, send me a message in-game username: "Kalfka"

or add me on discord "Kalfka#0083" and I would be happy to chat via voice to troubleshoot! It's taken a lot of trial and error to get the bot stable, as soon as I'm able to figure this problem out hopefully I'll be able to focus on gfx and embed layouts! And hopefully be live soon.

 

LINK TO SPK RAIDS FAM DISCORD SERVER: https://discord.gg/UEVcsv8cFq

 

Cheers,

Kalfka

 

also, if you are interested in ideas of how to implement any of these commands, here is a list!

 

?loadout [tob | cox] [cost]							output: ?loadout returns incremental sugguestions. 
  ex.) ?loadout tob 12000								includes item list, loadout image, prices, next upgrade at*
		
?item [itemid]									output: ?item returns item stats on relevent raid gear items
  ex.) ?item ancient_ward								includes item effects, applications (where to use them)
		
?droptable [tob | cox]								output: ?droptable returns a simple image with list
  ex.) ?droptable tob									includes item names and inventory icons

?droptable [tob | cox] [itemid]							output: ?droptable with the [itemid] argument returns specific item stats
  ex.) ?droptable tob sanguinesti_staff							includes item drop rate (GM), effects, stats, and applications

?droprates [tob | cox] [normal | ... | grandmasters]				output: ?droprates returns a table of droprates per item
  ex.) ?droprates tob grandmasters							includes grandmaster rates only as of now... but who knows the rest

?raidtime [tob | cox] [playercount] [normal | ... | grandmasters]		output: ?raidtime will give you an approximation of raid durtation by difficulty
  ex.) ?raidtime tob 5 grandmasters

?raidcalc									output: ?raidcalc returns the current gm-tob:gm-cox $/hr ratio
  ex.) ?raidcalc


?bossfight [vanguards | ... | verzik]
?rollchest [tob | cox] [normal | ... | grandmaster]

- Link #broadcasts to #loot-flex channel
- Link #updates
- Link #giveaways
- Link #killcount

 

Edited by Kalfka

Share this post


Link to post
Share on other sites
module.exports = {
    name:'tobloadout',
    description: 'Embeds!',
    execute : function(message, args, Discord) {
        const embed = new Discord.MessageEmbed()
        .setColor('#b92124')
        .setTitle('Theatre of Blood')
        .setURL('https://spawnpk.net/forums/index.php?/topic/26343-official-spawnpk-guide-index/')
        .setDescription('Loadout ID: ')
        .setImage('https://media.discordapp.net/attachments/906401044160983040/906401064041971772/test.png')
        .setThumbnail('https://media.discordapp.net/attachments/906401044160983040/914667694115127316/tob_relic.png')
        .addFields(
            {name: 'Melee', value: 'n', inline: true},
            {name: 'Range', value: 'n', inline: true}, 
            {name: 'Magic', value: 'n', inline: true},
 
            {name: 'Pets.', value: 'n', inline: true},
            {name: 'Misc.', value: 'n', inline: true},
            {name: 'Total', value: 'n', inline: true},
 
        )
        .setFooter('Next upgrade: n bags.');

        message.channel.send({ embeds: [embed] }); 
    }
}

 

Edited by Kalfka

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×