forked from viveksantayana/geas-bot
		
	15 July Nightly Commit
Split cogs into different files About to change file structuring to move dev file to main file
This commit is contained in:
		
							
								
								
									
										26
									
								
								app/dev_cogs/botcommands/prefix.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								app/dev_cogs/botcommands/prefix.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import yaml								# YAML parser for Bot config files
 | 
			
		||||
import asyncio							# Discord Py Dependency
 | 
			
		||||
import discord							# Main Lib
 | 
			
		||||
from discord.ext import commands		# Commands module
 | 
			
		||||
from dev import configFile, yaml_load, yaml_dump
 | 
			
		||||
 | 
			
		||||
### Cog for handling the non-Slash prefix for native Bot commands.
 | 
			
		||||
 | 
			
		||||
class Prefix(commands.Cog):
 | 
			
		||||
	def __init__(self, client):
 | 
			
		||||
		self.client = client
 | 
			
		||||
	
 | 
			
		||||
	@commands.command(
 | 
			
		||||
		name = 'changeprefix',
 | 
			
		||||
		aliases = ['prefix'],
 | 
			
		||||
		description = 'This command changes the prefix string for the native, non-slash command functionality of the bot. Defaults to `-`. It does not affect the workings of /commands.',
 | 
			
		||||
		brief = 'Changes the bot prefix.'		
 | 
			
		||||
	)
 | 
			
		||||
	async def _changePrefix(self, ctx, prefix:str = '-'):
 | 
			
		||||
		conf = yaml_load(configFile)
 | 
			
		||||
		conf[str(ctx.guild.id)]['prefix'] = prefix.lower()
 | 
			
		||||
		yaml_dump(conf, configFile)
 | 
			
		||||
		await ctx.send(f"`{self.client.user.name}`'s prefix for native bot commands has been changed to `{prefix}` for the guild `{ctx.guild.name}`.\n`Note: This will not affect /commands.`")
 | 
			
		||||
	
 | 
			
		||||
def setup(client):
 | 
			
		||||
	client.add_cog(Prefix(client))
 | 
			
		||||
		Reference in New Issue
	
	Block a user