Fix message command
This commit is contained in:
		
							parent
							
								
									98c031b5cd
								
							
						
					
					
						commit
						202a5adcd7
					
				| @ -3,46 +3,20 @@ const fn = require('../modules/functions.js'); | |||||||
| module.exports = { | module.exports = { | ||||||
| 	name: "message", | 	name: "message", | ||||||
| 	description: "Send a message to a server owner or server", | 	description: "Send a message to a server owner or server", | ||||||
| 	usage: ".message <serverID> <content>", | 	usage: "<serverID> <content>".message, | ||||||
| 	permission: "owner", | 	permission: "owner", | ||||||
| 	async execute(message, commandData) { | 	async execute(message, commandData) { | ||||||
| 		if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) { | 		if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) { | ||||||
| 			try { | 			try { | ||||||
| 				// Code Here
 | 				// Code Here
 | ||||||
| 				args = commandData.args.split(" "); | 				args = commandData.args.split(" "); | ||||||
| 				if (message.client.guildInfos.has(args[0])) { | 				const guildOwnerId = args.shift(); | ||||||
| 					let guildInfo = message.client.guildInfos.get(args[0]); | 				const content = args.join(" "); | ||||||
| 					const guild = await message.client.guilds.fetch(args[0]).catch(async e => { | 				const dmChannel = await message.client.users.createDM(guildOwnerId); | ||||||
| 						await message.reply("I was unable to fetch the guild."); | 				await dmChannel.send(content); | ||||||
| 						console.error(`Error fetching guild to send message: ${e}`); |  | ||||||
| 					}); |  | ||||||
| 					const guildOwner = await message.client.users.fetch(guild.ownerId).catch(async e => { |  | ||||||
| 						await message.reply("I was unable to fetch the guild owner."); |  | ||||||
| 						console.error(`Error fetching guild owner to send message: ${e}`); |  | ||||||
| 					}); |  | ||||||
| 					await guildOwner.createDM().then(async dm => { |  | ||||||
| 						await dm.send(args.join(" ")).catch(async e => { |  | ||||||
| 							await message.reply("I was unable to send the DM."); |  | ||||||
| 							console.error(`Error sending DM message: ${e}`); |  | ||||||
| 						}); |  | ||||||
| 					}).catch(async e => { |  | ||||||
| 						await message.reply("I was unable to create the DM."); |  | ||||||
| 						console.error(`Error creating DM to send message: ${e}`); |  | ||||||
| 						const channel = await guild.channels.fetch(guildInfo.reminderChannelId).catch(async e => { |  | ||||||
| 							await message.reply("I was unable to fetch the channel."); |  | ||||||
| 							console.error(`Error fetching channel to send message: ${e}`); |  | ||||||
| 						}); |  | ||||||
| 						await channel.send(args.join(" ")).catch(async e => { |  | ||||||
| 							await message.reply("I was unable to send the message."); |  | ||||||
| 							console.error(`Error sending message: ${e}`); |  | ||||||
| 						}); |  | ||||||
| 					}); |  | ||||||
| 				} else { |  | ||||||
| 					throw "Guild doesn't exist in database!"; |  | ||||||
| 				} |  | ||||||
| 			} catch (err) { | 			} catch (err) { | ||||||
| 				console.error(err); | 				console.error(err); | ||||||
| 				await message.reply(fn.builders.errorEmbed("There was an error running the command.")); | 				await message.reply(fn.builders.errorEmbed("There was an error running the command: " + err)); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -257,7 +257,7 @@ const functions = { | |||||||
| 			} | 			} | ||||||
| 			commandData.isCommand = true; | 			commandData.isCommand = true; | ||||||
| 			// Get the first part of the message, everything leading up to the final period
 | 			// Get the first part of the message, everything leading up to the final period
 | ||||||
| 			commandData.args = message.content.slice(0, finalPeriod).toLowerCase(); | 			commandData.args = message.content.slice(0, finalPeriod); | ||||||
| 			// Get the last part of the message, everything after the final period
 | 			// Get the last part of the message, everything after the final period
 | ||||||
| 			commandData.command = message.content.slice(finalPeriod).replace('.', '').toLowerCase(); | 			commandData.command = message.content.slice(finalPeriod).replace('.', '').toLowerCase(); | ||||||
| 			commandData.author = `${message.author.username}#${message.author.discriminator}`; | 			commandData.author = `${message.author.username}#${message.author.discriminator}`; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user