Python discord.ext.commands.when_mentioned_or() Examples
The following are 11
code examples of discord.ext.commands.when_mentioned_or().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord.ext.commands
, or try the search function
.
Example #1
Source File: bot.py From NotSoBot with MIT License | 6 votes |
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 = {}
Example #2
Source File: __init__.py From code-jam-5 with MIT License | 6 votes |
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}')
Example #3
Source File: bot.py From Penny-Dreadful-Tools with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: dbot.py From avrae with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: main.py From modmail with GNU Affero General Public License v3.0 | 5 votes |
def _get_guild_prefix(bot2, message): prefix = get_guild_prefix(bot2, message.guild) return commands.when_mentioned_or(prefix)(bot2, message)
Example #6
Source File: bot.py From DHV3 with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #7
Source File: bot.py From rewrite with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: main.py From RulesBot with MIT License | 5 votes |
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)
Example #9
Source File: bot.py From Firetail with MIT License | 5 votes |
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)
Example #10
Source File: appv2.py From code-jam-5 with MIT License | 5 votes |
def __init__(self, **kwargs): super().__init__(command_prefix=commands.when_mentioned_or('!'), **kwargs) for cog in cogs: self.load_extension(f'cogs.{cog}')
Example #11
Source File: __main__.py From code-jam-5 with MIT License | 5 votes |
def get_prefix(client, message): prefixes = os.environ.get("DISCORD_PREFIX") return commands.when_mentioned_or(*prefixes)(client, message)