mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Core] Mentionable prefix (#1256)
* allow mentioning the bot as a fallback to a prefix * make this toggleable
This commit is contained in:
parent
55bbbe6268
commit
1b45397e67
@ -9,6 +9,7 @@ from pathlib import Path
|
||||
import discord
|
||||
from discord.ext.commands.bot import BotBase
|
||||
from discord.ext.commands import GroupMixin
|
||||
from discord.ext.commands import when_mentioned_or
|
||||
|
||||
from .cog_manager import CogManager
|
||||
from . import (
|
||||
@ -76,7 +77,12 @@ class RedBase(BotBase, RpcMethodMixin):
|
||||
if message.guild is None:
|
||||
return global_prefix
|
||||
server_prefix = await bot.db.guild(message.guild).prefix()
|
||||
return server_prefix if server_prefix else global_prefix
|
||||
if cli_flags.mentionable:
|
||||
return when_mentioned_or(*server_prefix)(bot, message) \
|
||||
if server_prefix else \
|
||||
when_mentioned_or(*global_prefix)(bot, message)
|
||||
else:
|
||||
return server_prefix if server_prefix else global_prefix
|
||||
|
||||
if "command_prefix" not in kwargs:
|
||||
kwargs["command_prefix"] = prefix_manager
|
||||
|
||||
@ -105,6 +105,10 @@ def parse_cli_flags(args):
|
||||
parser.add_argument("--dev",
|
||||
action="store_true",
|
||||
help="Enables developer mode")
|
||||
parser.add_argument("--mentionable",
|
||||
action="store_true",
|
||||
help="Allows mentioning the bot as an alternative "
|
||||
"to using the bot prefix")
|
||||
parser.add_argument("--rpc",
|
||||
action="store_true",
|
||||
help="Enables the built-in RPC server. Please read the docs"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user