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


Python commands.group方法代码示例

本文整理汇总了Python中discord.ext.commands.group方法的典型用法代码示例。如果您正苦于以下问题:Python commands.group方法的具体用法?Python commands.group怎么用?Python commands.group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.ext.commands的用法示例。


在下文中一共展示了commands.group方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: beyond

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def beyond(self, ctx, url: str, *args):
        """
        Loads a character sheet from [D&D Beyond](https://www.dndbeyond.com/), resetting all settings.
        __Valid Arguments__
        `-nocc` - Do not automatically create custom counters for limited use features.
        """

        loading = await ctx.send('Loading character data from Beyond...')
        url = DDB_URL_RE.match(url)
        if url is None:
            return await loading.edit(content="This is not a D&D Beyond link.")
        url = url.group(1)

        override = await self._confirm_overwrite(ctx, f"beyond-{url}")
        if not override: return await ctx.send("Character overwrite unconfirmed. Aborting.")

        parser = BeyondSheetParser(url)
        await self._load_sheet(ctx, parser, args, loading) 
开发者ID:avrae,项目名称:avrae,代码行数:20,代码来源:sheetManager.py

示例2: remove_combatant

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def remove_combatant(self, ctx, *, name: str):
        """Removes a combatant or group from the combat.
        Usage: !init remove <NAME>"""
        combat = await Combat.from_ctx(ctx)

        combatant = await combat.select_combatant(name, select_group=True)
        if combatant is None:
            return await ctx.send("Combatant not found.")

        if combatant is combat.current_combatant:
            return await ctx.send("You cannot remove a combatant on their own turn.")

        if combatant.group is not None:
            group = combat.get_group(combatant.group)
            if len(group.get_combatants()) <= 1 and group is combat.current_combatant:
                return await ctx.send(
                    "You cannot remove a combatant if they are the only remaining combatant in this turn.")
        combat.remove_combatant(combatant)
        await ctx.send("{} removed from combat.".format(combatant.name))
        await combat.final() 
开发者ID:avrae,项目名称:avrae,代码行数:22,代码来源:initTracker.py

示例3: tome_sub

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def tome_sub(self, ctx, url):
        """Subscribes to another user's tome."""
        tome_id_match = re.search(r"homebrew/spells/([0-9a-f]{24})/?", url)
        if not tome_id_match:
            return await ctx.send("Invalid tome URL.")
        try:
            tome = await Tome.from_id(ctx, tome_id_match.group(1))
        except NoActiveBrew:
            return await ctx.send("Pack not found.")

        if not tome.public:
            return await ctx.send("This tome is not public.")

        await tome.subscribe(ctx)
        await ctx.send(f"Subscribed to {tome.name}. "  # by {tome.owner['username']}. "  # todo
                       f"Use `{ctx.prefix}tome {tome.name}` to select it.") 
开发者ID:avrae,项目名称:avrae,代码行数:18,代码来源:homebrew.py

示例4: uniquegroup

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def uniquegroup(self, ctx, role: discord.Role, groupid: int):
        """Set a role to a unique group ID,
        This means that a user cannot have more then one role from the same group.

        Any role sharing the same ID will be considered a group.
        GroupID 0 will not be considered unique and can share other roles."""
        server = ctx.message.server
        if role.id not in self.settings_dict[server.id]['roles']:
            await self.bot.say('This role ins\'t in the buyrole list')
        elif groupid < 0:
            await self.bot.say('The group ID cannot be negative.')
        else:
            # Set the uniquegroup ID here, logic will remain in a subfunction of buyrole
            self.settings_dict[server.id]['roles'][role.id]['uniquegroup'] = groupid
            self.save_json()
            if groupid == 0:
                await self.bot.say('Unique Group ID set. {} isn\'t considered unique.'.format(role.name))
            else:
                await self.bot.say('Unique Group ID set. {} will now be unique in group ID {}'.format(role.name, groupid)) 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:21,代码来源:buyrole.py

示例5: autorole_remove

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def autorole_remove(self, ctx: NabCtx, role: InsensitiveRole, *, guild: str):
        """Removes an autorole rule.

        Role names, mentions and ids are accepted. Role names with multiple words need to be quoted.

        Note that members that currently have the role won't be affected."""
        group: discord.Role = role
        guild = guild.replace("\"", "")
        exists = await ctx.pool.fetchval("SELECT true FROM role_auto WHERE role_id = $1 AND lower(rule) = $2",
                                         group.id, guild.lower())
        if not exists:
            await ctx.error("That rule doesn't exist.")
            return

        # Can't modify role higher than the owner's top role
        top_role: discord.Role = ctx.author.top_role
        if group >= top_role:
            await ctx.error("You can't delete a role rule for a role higher than yours.")
            return

        await ctx.success(f"Auto role rule removed. Note that the role won't be removed from current members.")
        await ctx.pool.execute("DELETE FROM role_auto WHERE role_id = $1 AND lower(rule) = $2", group.id, guild.lower()) 
开发者ID:NabDev,项目名称:NabBot,代码行数:24,代码来源:roles.py

示例6: loot_show

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def loot_show(self, ctx, *, item: str):
        """Shows item info from loot database."""
        result, item_list = await self.item_show(item)

        if not item_list:
            return await ctx.error("There's no item with that name.")
        item = item_list[0]
        embed = discord.Embed(title=item["name"], description=f"Group: {item['group']}",
                              colour=discord.Colour.from_rgb(item["red"], item["green"], item["blue"]))
        content = ""
        for item in item_list:
            content += "ID: {id} | Size: {sizeX}x{sizeY} | {size}px | rgb: {red},{green},{blue} | " \
                       "sell: {value_sell:,} | buy: {value_buy:,}\n".format(**item)
        fields = split_message(content, FIELD_VALUE_LIMIT)
        name = "Frame info"
        for i, field in enumerate(fields[:5]):
            if i:
                name = "\u200F"
            embed.add_field(name=name, value=field, inline=False)
        if len(fields) > 5:
            embed.set_footer(text="Too many frames to display all information.")
        embed.set_image(url="attachment://results.png")
        await ctx.send(embed=embed, file=discord.File(io.BytesIO(result), "results.png")) 
开发者ID:NabDev,项目名称:NabBot,代码行数:25,代码来源:loot.py

示例7: draftutil_cards

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def draftutil_cards(self, ctx):
        """List available cards by emojis."""
        emojis = [v["emoji"] for k, v in self.crdata["Cards"].items()]

        groups = grouper(emojis, 25)
        for group in groups:
            out = []
            for emoji in group:
                if emoji is not None:
                    out.append('<:{}:{}>'.format(emoji, self.emojis[emoji]))
            await self.bot.say(' '.join(out))
        # out = []
        # for emoji in emojis:
        #     if emoji is not None:
        #         out.append('<:{}:{}>'.format(emoji, self.emojis[emoji]))
        # em = discord.Embed()
        # em.add_field(name="", value="".join(out))
        # await self.bot.say(embed=em) 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:20,代码来源:draftroyale.py

示例8: get_channel_params

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def get_channel_params(self, channel: Channel):
        """Return extra fields for channel."""
        extra = {
            'id': channel.id,
            'name': channel.name,
            'server': self.get_server_params(channel.server),
            'position': channel.position,
            'is_default': channel.is_default,
            'created_at': channel.created_at.isoformat(),
            'type': {
                'text': channel.type == ChannelType.text,
                'voice': channel.type == ChannelType.voice,
                'private': channel.type == ChannelType.private,
                'group': channel.type == ChannelType.group
            }
        }
        return extra 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:19,代码来源:logstash.py

示例9: decklink_to_cards

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def decklink_to_cards(self, url):
        """Convert decklink to cards."""
        card_keys = None
        # search for Clash Royale decks
        m_crlink = re.search('(http|ftp|https)://link.clashroyale.com/deck/..\?deck=[\d\;]+', url)

        # search for royaleapi deck stats link
        m_rapilink = re.match('(https|http)://royaleapi.com/decks/stats/([a-z,-]+)/?', url)
        m_rapilink_section = re.match('(https|http)://royaleapi.com/decks/stats/([a-z,-]+)/.+', url)

        if m_crlink:
            url = m_crlink.group()
            decklinks = re.findall('2\d{7}', url)
            card_keys = []
            for decklink in decklinks:
                card_key = await self.card_decklink_to_key(decklink)
                if card_key is not None:
                    card_keys.append(card_key)
        elif m_rapilink and not m_rapilink_section:
            s = m_rapilink.group(2)
            card_keys = s.split(',')

        return card_keys 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:25,代码来源:deck.py

示例10: cache_pois

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def cache_pois(self):
        async def bulk_write(group):
            requests = []
            for item in group:
                item["_id"] = item.pop("id")
                requests.append(
                    ReplaceOne({"_id": item["_id"]}, item, upsert=True))
            try:
                await self.db.pois.bulk_write(requests)
            except BulkWriteError as e:
                self.log.exception("BWE while caching continents")

        continents = await self.call_api("continents/1/floors?ids=all")
        pois = []
        for continent in continents:
            for region in continent["regions"].values():
                for game_map in region["maps"].values():
                    for poi in game_map["points_of_interest"].values():
                        del poi["chat_link"]
                        poi["continent_id"] = continent["id"]
                        pois.append(poi)
                        if len(pois) > 200:
                            await bulk_write(pois)
                            pois = []
        print("Continents done") 
开发者ID:Maselkov,项目名称:GW2Bot,代码行数:27,代码来源:database.py

示例11: add_synonym

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def add_synonym(self, other):
        """Every word in a group of synonyms shares the same list."""
        self.synonyms.extend(other.synonyms)
        other.synonyms = self.synonyms 
开发者ID:irdumbs,项目名称:Dumb-Cogs,代码行数:6,代码来源:adventure.py

示例12: status

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def status(self, ctx, name: str, *, args: str = ''):
        """Gets the status of a combatant or group.
        __Valid Arguments__
        private - PMs the controller of the combatant a more detailed status."""
        combat = await Combat.from_ctx(ctx)
        combatant = await combat.select_combatant(name, select_group=True)
        if combatant is None:
            await ctx.send("Combatant or group not found.")
            return

        private = 'private' in args.lower()
        if not isinstance(combatant, CombatantGroup):
            private = private and str(ctx.author.id) == combatant.controller
            status = combatant.get_status(private=private)
            if private and isinstance(combatant, MonsterCombatant):
                status = f"{status}\n* This creature is a {combatant.monster_name}."
        else:
            status = "\n".join([co.get_status(private=private and str(ctx.author.id) == co.controller) for co in
                                combatant.get_combatants()])

        if private:
            controller = ctx.guild.get_member(int(combatant.controller))
            if controller:
                await controller.send("```markdown\n" + status + "```")
        else:
            await ctx.send("```markdown\n" + status + "```") 
开发者ID:avrae,项目名称:avrae,代码行数:28,代码来源:initTracker.py

示例13: remove_effect

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def remove_effect(self, ctx, name: str, effect: str = None):
        """Removes a status effect from a combatant or group. Removes all if effect is not passed."""
        combat = await Combat.from_ctx(ctx)

        targets = []

        target = await combat.select_combatant(name, select_group=True)
        if isinstance(target, CombatantGroup):
            targets.extend(target.get_combatants())
        else:
            targets.append(target)

        out = ""

        for combatant in targets:
            if effect is None:
                combatant.remove_all_effects()
                out += f"All effects removed from {combatant.name}.\n"
            else:
                to_remove = await combatant.select_effect(effect)
                children_removed = ""
                if to_remove.children:
                    children_removed = f"Also removed {len(to_remove.children)} child effects.\n"
                to_remove.remove()
                out += f'Effect {to_remove.name} removed from {combatant.name}.\n{children_removed}'
        await ctx.send(out)
        await combat.final() 
开发者ID:avrae,项目名称:avrae,代码行数:29,代码来源:initTracker.py

示例14: _new_message

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def _new_message(self, message):
        """Finds the message and checks it for regex"""
        user = message.author
        if message.server is None:
            return
        if message.server.id in self.json:

            if self.json[message.server.id]['toggle'] is True:

                roles = [r.name for r in user.roles]
                bot_admin = settings.get_server_admin(message.server)
                bot_mod = settings.get_server_mod(message.server)
                if message.channel.id in self.json[message.server.id]['excluded_channels']:
                    return
                elif user.id == settings.owner:
                    return
                elif bot_admin in roles:
                    return
                elif bot_mod in roles:
                    return
                elif user.permissions_in(message.channel).manage_messages is True:
                    return
                elif user == message.server.me:
                    return

                if self.json[message.server.id]['strict']:
                    for match in self.regex_url.finditer(message.content):
                        if self.emoji_string not in match.group(0):
                            asyncio.sleep(0.5)
                            await self.bot.delete_message(message)
                            if self.json[message.server.id]['dm'] is True:
                                await self.bot.send_message(message.author, self.json[message.server.id]['message'])
                            break
                elif self.regex.search(message.content) is not None or self.regex_discordme.search(message.content) is not None:

                    asyncio.sleep(0.5)
                    await self.bot.delete_message(message)
                    if self.json[message.server.id]['dm'] is True:
                        await self.bot.send_message(message.author, self.json[message.server.id]['message']) 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:41,代码来源:antilink.py

示例15: check_match

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import group [as 别名]
def check_match(predicate: Callable[[str], Optional[SRE_Match]], string: str) -> dict:
    """
    Match task worker.

    Takes a predicate returning a regex match and the string to pass it.
    Returns a dict of time elapsed and match information (if any) or any match exception.
    """
    t0 = time.perf_counter()
    ret = {}

    try:
        match = predicate(string)
    except Exception as e:
        match = None
        ret['exception'] = e

    elapsed = time.perf_counter() - t0

    ret['time'] = elapsed

    if match:
        ret['match'] = match.group(0)
        ret['span'] = match.span(0)
        groups = match.groups()

        if groups:
            ret.update({
                'group_matches' : tuple(match.group(i + 1) for i in range(len(groups))),
                'group_spans'   : tuple(match.span(i + 1) for i in range(len(groups))),
                'groupdict'     : match.groupdict(),
                'groups'        : groups
            })

    return ret 
开发者ID:calebj,项目名称:calebj-cogs,代码行数:36,代码来源:recensor.py


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