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 bot import configFile, yaml_load, yaml_dump ### Cog for handling the non-Slash prefix for native Bot commands. class Prefix(commands.Cog, name='Server Command Prefix'): 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))