本文整理汇总了Python中discord.ext.commands.when_mentioned_or方法的典型用法代码示例。如果您正苦于以下问题:Python commands.when_mentioned_or方法的具体用法?Python commands.when_mentioned_or怎么用?Python commands.when_mentioned_or使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.ext.commands
的用法示例。
在下文中一共展示了commands.when_mentioned_or方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def __init__(self, *args, **kwargs):
self.loop = kwargs.pop('loop', asyncio.get_event_loop())
asyncio.get_child_watcher().attach_loop(self.loop)
self.dev_mode = kwargs.pop('dev_mode', False)
self.token = os.getenv('bot_token') if not self.dev_mode else os.getenv('bot_beta_token')
self.self_bot = kwargs.pop('self_bot', False)
if self.self_bot:
self.token = os.getenv('notsosuper_token')
shard_id = kwargs.get('shard_id', 0)
command_prefix = kwargs.pop('command_prefix', commands.when_mentioned_or('.'))
init_logging(shard_id, self)
super().__init__(command_prefix=command_prefix, *args, **kwargs)
self.remove_command('help')
init_funcs(self)
self.owner = None
self.start_time = time.time()
self.own_task = None
self.last_message = None
self.command_messages = {}
示例2: __init__
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def __init__(self):
super().__init__(command_prefix=commands.when_mentioned_or('>'),
description=description,
case_insensitive=True
)
config = Config.load(config_path)
self.client_id = config.client_id
self.owner_id = config.owner_id
self.session = aiohttp.ClientSession(loop=self.loop)
self.colour = discord.Colour.blurple()
self.help_command = Help()
self.db = get_db()
for ext in extensions:
try:
self.load_extension(ext)
except Exception as e:
tb.print_exc()
print(f'Failed to load {ext}: {e}')
示例3: __init__
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def __init__(self, **kwargs: Any) -> None:
self.launch_time = perf.start()
commit_id = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode()
redis.store('discordbot:commit_id', commit_id)
super().__init__(command_prefix=commands.when_mentioned_or('!'), help_command=commands.DefaultHelpCommand(dm_help=True), case_insensitive=True, **kwargs)
self.voice = None
self.achievement_cache: Dict[str, Dict[str, str]] = {}
for task in TASKS:
asyncio.ensure_future(task(self), loop=self.loop)
discordbot.commands.setup(self)
示例4: get_prefix
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def get_prefix(the_bot, message):
if not message.guild:
return commands.when_mentioned_or(config.DEFAULT_PREFIX)(the_bot, message)
guild_id = str(message.guild.id)
if guild_id in the_bot.prefixes:
gp = the_bot.prefixes.get(guild_id, config.DEFAULT_PREFIX)
else: # load from db and cache
gp_obj = await the_bot.mdb.prefixes.find_one({"guild_id": guild_id})
if gp_obj is None:
gp = config.DEFAULT_PREFIX
else:
gp = gp_obj.get("prefix", config.DEFAULT_PREFIX)
the_bot.prefixes[guild_id] = gp
return commands.when_mentioned_or(gp)(the_bot, message)
示例5: _get_guild_prefix
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def _get_guild_prefix(bot2, message):
prefix = get_guild_prefix(bot2, message.guild)
return commands.when_mentioned_or(prefix)(bot2, message)
示例6: get_prefix
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def get_prefix(bot, message):
extras = [await bot.db.get_pref(message.channel, "prefix"), "duckhunt", "dh!", "dh", "Dh", "Dh!", "dH!", "dH", "DH!", "DH"]
return commands.when_mentioned_or(*extras)(bot, message)
示例7: prefix_from
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def prefix_from(bot, msg):
prefixes = set()
if msg.guild:
prefixes.add(bot.prefix_map.get(msg.guild.id, bot.bot_settings.prefix))
else:
prefixes.add(bot.bot_settings.prefix)
return commands.when_mentioned_or(*prefixes)(bot, msg)
示例8: get_server_prefix
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def get_server_prefix(bot: commands.Bot, message: discord.Message):
if not message.guild:
return '-'
server_settings: ServerSettings = ServerSettings.get_or_insert(message.guild)
return commands.when_mentioned_or(server_settings.prefix)(bot, message)
示例9: prefix_manager
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def prefix_manager(bot, message):
if not message.guild:
return commands.when_mentioned_or(bot.default_prefix)(bot, message)
prefix = bot.prefixes.get(message.guild.id) or bot.default_prefix
return commands.when_mentioned_or(prefix)(bot, message)
示例10: __init__
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def __init__(self, **kwargs):
super().__init__(command_prefix=commands.when_mentioned_or('!'),
**kwargs)
for cog in cogs:
self.load_extension(f'cogs.{cog}')
示例11: get_prefix
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import when_mentioned_or [as 别名]
def get_prefix(client, message):
prefixes = os.environ.get("DISCORD_PREFIX")
return commands.when_mentioned_or(*prefixes)(client, message)