diff --git a/commands/admin/setup.js b/commands/admin/setup.js index 3c897e7..d99c8d8 100644 --- a/commands/admin/setup.js +++ b/commands/admin/setup.js @@ -36,17 +36,21 @@ async function execute(bot, message, args, command, Discord, mongouri, items, xp //Chose the appropriate command command = args[0]; - if (args[1] == undefined) { - return message.reply("Please specify what the new value is!"); - } if (command == 'welcome_channel') { - if (args.length != 2) { return message.reply('The command format is _!setup welcomechannel _'); } + if (args.length != 2) { return message.reply('The command format is _!setup welcome_channel _'); } // setWelcomeChannel(dbo, message, args[1]); const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); dbo.updateOne({welcomechannel: {$exists: true}}, {$set: {welcomechannel: `${channel.id}`}}); } else if (command == 'welcome_message') { - dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: args[1]}}) + if (args.length < 2) { return message.reply('The command format is _!setup welcome\\_message_\nUse _{sn}_ to insert the server name, _{un}_ to insert the user name, and _{ut}_ to insert the user tag\nExample: _!setup welcome\\_message Welcome to {sn} Sir {un}#{ut}_'); } + let msg = ""; + for (let i = 1; i < args.length; i ++ ) { + msg += args[i] + ' '; + } + + if (msg.length > 30) { return message.reply('Please specify a welcome message under 30 characters!'); } + dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: msg}}) } }); diff --git a/commands/admin/welcome.js b/commands/admin/welcome.js index e11e9c6..23c5e03 100644 --- a/commands/admin/welcome.js +++ b/commands/admin/welcome.js @@ -54,10 +54,14 @@ async function welcome(member, welcomechannel, welcomemessage = null, welcomeban //message.author.username == interaction.member.displayName //message.guild.name == interaction.member.guild.name - let txt = 'Welcome to'; - if (welcomemessage != null) { txt = welcomemessage} + let text = `Welcome to ${member.guild.name} ${member.user.username}#${member.user.discriminator}!`; + if(welcomemessage != null) { + text = welcomemessage; + text = text.replace('{sn}', member.guild.name); + text = text.replace('{un}', member.user.username); + text = text.replace('{ut}', member.user.discriminator); + } - const text = `${txt} ${member.guild.name} ${member.user.username}#${member.user.discriminator}!`; context.font = applyText(canvas, text); context.fillStyle = '#ffffff'; context.fillText(text, (canvas.width/2) - (text.length * 7.5), canvas.height - 15);