mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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
|
import discord
|
||||||
from discord.ext.commands.bot import BotBase
|
from discord.ext.commands.bot import BotBase
|
||||||
from discord.ext.commands import GroupMixin
|
from discord.ext.commands import GroupMixin
|
||||||
|
from discord.ext.commands import when_mentioned_or
|
||||||
|
|
||||||
from .cog_manager import CogManager
|
from .cog_manager import CogManager
|
||||||
from . import (
|
from . import (
|
||||||
@ -76,6 +77,11 @@ class RedBase(BotBase, RpcMethodMixin):
|
|||||||
if message.guild is None:
|
if message.guild is None:
|
||||||
return global_prefix
|
return global_prefix
|
||||||
server_prefix = await bot.db.guild(message.guild).prefix()
|
server_prefix = await bot.db.guild(message.guild).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
|
return server_prefix if server_prefix else global_prefix
|
||||||
|
|
||||||
if "command_prefix" not in kwargs:
|
if "command_prefix" not in kwargs:
|
||||||
|
|||||||
@ -105,6 +105,10 @@ def parse_cli_flags(args):
|
|||||||
parser.add_argument("--dev",
|
parser.add_argument("--dev",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Enables developer mode")
|
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",
|
parser.add_argument("--rpc",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Enables the built-in RPC server. Please read the docs"
|
help="Enables the built-in RPC server. Please read the docs"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user