diff --git a/commands/config.js b/commands/config.js index acce583..e7fcbfa 100644 --- a/commands/config.js +++ b/commands/config.js @@ -364,6 +364,19 @@ module.exports = { required: true, }] }, + { + name: "welcome_message_server_name", + description: "Configure the server name in the welcome message", + value: "welcome_message_server_name", + type: CommandOptions.SubCommand, + options: [{ + name: "name", + desciption: "Server name to include in welcome message", + value: "name", + type: CommandOptions.String, + required: true, + }] + } ], SlashCommand: { /** @@ -787,6 +800,19 @@ module.exports = { } + case 'welcome_message_server_name': + const server_name = args[0].options[0].value; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.serverName":server_name}}, (err, res) => { + if (err) return client.sendInternalError(interacion, err); + }); + + const succcessUpdateServerName = new EmbedBuilder() + .setDescription(`Successfully configured the server name to **${server_name}** in the welcome message.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [succcessUpdateServerName] }); + default: return client.sendInternalError(interaction, 'There was an error parsing the config command'); } diff --git a/database/guild.js b/database/guild.js index 61a92d1..35ee3a3 100644 --- a/database/guild.js +++ b/database/guild.js @@ -16,6 +16,7 @@ module.exports = { return { serverID: GuildId, + serverName: guild.server.serverName, autoRestart: guild.server.autoRestart, showKillfeedCoords: guild.server.showKillfeedCoords, showKillfeedWeapon: guild.server.showKillfeedWeapon, @@ -57,6 +58,7 @@ module.exports = { getDefaultSettings(GuildId) { return { serverID: GuildId, + serverName: "our server!", autoRestart: 0, showKillfeedCoords: 0, showKillfeedWeapon: 0, diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index ce3a89c..f128f74 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -4,11 +4,14 @@ const { GetGuild } = require('../database/guild'); module.exports = async (client, member) => { let GuildDB = await GetGuild(client, member.guild.id); + if (!client.exists(GuildDB.welcomeChannel)) return; const channel = client.GetChannel(GuildDB.welcomeChannel); + if (GuildDB.serverName == "") GuildDB.serverName = "our server!" + let embed = new EmbedBuilder() .setColor(client.config.Colors.Default) - .setDescription(`**Welcome** <@${member.user.id}> to **DayZ Reforger**\nTo gain access please use the command `); + .setDescription(`**Welcome** <@${member.user.id}> to **${GuildDB.serverName}**\nUse the command to link your Discord to your gamertag.`); channel.send({ content: `<@${member.user.id}>`, embeds: [embed] }); }; diff --git a/package.json b/package.json index 48b3958..772d3b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "12.6.0", + "version": "12.7.0", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": {