當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。