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:
parent
a74c08867a
commit
1ecd790f83
2 changed files with 181 additions and 163 deletions
|
@ -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}')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue