当前位置: 首页>>代码示例>>Python>>正文


Python commands.when_mentioned_or方法代码示例

本文整理汇总了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 = {} 
开发者ID:NotSoSuper,项目名称:NotSoBot,代码行数:21,代码来源:bot.py

示例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}') 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:24,代码来源:__init__.py

示例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) 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:13,代码来源:bot.py

示例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) 
开发者ID:avrae,项目名称:avrae,代码行数:16,代码来源:dbot.py

示例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) 
开发者ID:CHamburr,项目名称:modmail,代码行数:5,代码来源:main.py

示例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) 
开发者ID:DuckHunt-discord,项目名称:DHV3,代码行数:5,代码来源:bot.py

示例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) 
开发者ID:initzx,项目名称:rewrite,代码行数:9,代码来源:bot.py

示例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) 
开发者ID:BaseChip,项目名称:RulesBot,代码行数:7,代码来源:main.py

示例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) 
开发者ID:shibdib,项目名称:Firetail,代码行数:8,代码来源:bot.py

示例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}') 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:7,代码来源:appv2.py

示例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) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:6,代码来源:__main__.py


注:本文中的discord.ext.commands.when_mentioned_or方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。