const commandBase = require('../modules/commandBase')

module.exports = class prefix extends commandBase {
	constructor() {
		super()
		this.disableDMs  = 'Prefixes are not used in direct messages.'
		this.description = 'Views or sets a servers\'s prefix'
		this.usage.args  = '[new prefix]'
		this.usage.text  = 'If a new prefix is not specifed, returns the server\'s current prefix. Otherwise, sets ' +
			'the server\'s new prefix. (Requires MANAGE_GUILD permission.)'
	}
	async execute(msg, args) {
		let db = msg.client.db

		if(!args[0]) {
			let doc = await db.ensureIDExists(msg.guild.id)
			msg.reply(doc.prefix ?
				`This server's prefix is \`${doc.prefix}\`.` : 'This server does not have a prefix defined.')

		} else if(msg.member.hasPermission('MANAGE_GUILD')) {
			let doc = await db.ensureIDExists(msg.guild.id)
			if(doc.prefix == args[0]) return msg.reply(`This server's prefix is already \`${doc.prefix}\`!`)

			await db.update({_id: doc._id}, {$set:{prefix: args[0]}})
			let newDoc      = await db.ensureIDExists(msg.guild.id)

			msg.reply(`This server's prefix is now \`${newDoc.prefix}\`.`)

		} else {
			msg.reply('You do not have permission to set the prefix for this server.')
		}

	}
}

@@ -282,16 +282,28 @@
 w prefix
+,%5C'disable%5C'
 %5D'%0A%09%09thi
@@ -326,45 +326,33 @@
 'If 
-a new prefix is not
+no argument is
  specif
+i
 ed,
- returns
  the
@@ -380,95 +380,245 @@
 efix
-. Otherwise, sets ' +%0A%09%09%09'the server%5C's new prefix. (Requires MANAGE_GUILD permission.)
+ is returned. If a string that ' +%0A%09%09%09'is not %5C'disable%5C', it will be set as the new prefix. If %5C'disable%5C' is specifed, the server%5C's prefix ' +%0A%09%09%09'will be disabled. %5Cn%5CnMANAGE_GUILD permission is required to modify a server%5C's prefix.
 '%0A%09%7D
@@ -856,16 +856,8 @@
 efix
- defined
 .')%0A
@@ -909,24 +909,84 @@
 _GUILD')) %7B%0A
+%09%09%09let prefix = args%5B0%5D == 'disable' ? undefined : args%5B0%5D;%0A
 %09%09%09let doc =
@@ -1024,16 +1024,17 @@
 ild.id)%0A
+%0A
 %09%09%09if(do
@@ -1045,23 +1045,22 @@
 efix == 
-args%5B0%5D
+prefix
 ) return
@@ -1062,33 +1062,33 @@
 eturn msg.reply(
-%60
+%22
 This server's pr
@@ -1096,40 +1096,31 @@
 fix 
-is already %5C%60$%7Bdoc.prefix%7D%5C%60!%60)%0A
+has not been modifed.%22)
 %0A%09%09%09
@@ -1157,16 +1157,17 @@
 , %7B$set:
+ 
 %7Bprefix:
@@ -1171,19 +1171,19 @@
 ix: 
-args%5B0%5D
+prefix
 %7D%7D)%0A
+%0A
 %09%09%09l
@@ -1192,21 +1192,16 @@
  newDoc 
-     
 = await 
@@ -1246,16 +1246,36 @@
 g.reply(
+newDoc.prefix ?%0A%09%09%09%09
 %60This se
@@ -1317,18 +1317,57 @@
 fix%7D%5C%60.%60
+ : 'This server no longer has a prefix.'
 )
-%0A
 %0A%09%09%7D els
@@ -1414,19 +1414,22 @@
 sion to 
-set
+modify
  the pre

Allow server's prefix to be disabled.