1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 14:27:27 +00:00

Prefix per guild command

This commit is contained in:
Myned 2017-10-20 16:16:05 -04:00
parent a74c08867a
commit 1ecd790f83
2 changed files with 181 additions and 163 deletions

View file

@ -178,3 +178,15 @@ class Administration:
await ctx.send('**Delete command invocations:** `{}`'.format(ctx.guild.id in u.settings['del_ctx']))
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
@commands.command(name='setprefix', aliases=['setpre', 'spre'])
@commands.has_permissions(administrator=True)
async def set_prefix(self, ctx, prefix=None):
if prefix is not None:
u.settings['prefixes'][ctx.guild.id] = prefix
else:
with suppress(KeyError):
del u.settings['prefixes'][ctx.guild.id]
await ctx.send(f'**Prefix set to:** `{"` or `".join(prefix if ctx.guild.id in u.settings["prefixes"] else u.config["prefix"])}`')
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')

View file

@ -18,8 +18,14 @@ from utils import utils as u
# log.basicConfig(level=log.INFO)
bot = commands.Bot(command_prefix=u.config['prefix'], description='Experimental miscellaneous bot')
def get_prefix(bot, message):
if isinstance(message.guild, d.Guild) and message.guild.id in u.settings['prefixes']:
return u.settings['prefixes'][message.guild.id]
return u.config['prefix']
bot = commands.Bot(command_prefix=get_prefix, description='Experimental miscellaneous bot')
# Send and print ready message to #testing and console after logon
@bot.event