示例#1
0
    def __init__(self, **kwargs):
        self.default_prefix = config.bot_prefix
        self.owner = config.bot_master
        self._shutdown_mode = ExitCodes.CRITICAL
        self.counter = Counter()
        self.core_dir = os.path.dirname(os.path.realpath(__file__))
        self.config = config
        self.default_prefix = config.bot_prefix[0]
        self.prefixes = {}
        self.bot_users = []
        self.repeat_offender = []
        self.last_command = None
        self.token = config.bot_token
        self.req_perms = discord.Permissions(config.bot_permissions)
        self.co_owners = config.bot_coowners
        self.fcping_managers = config.fcping_managers
        self.rorqstatus_managers = config.rorqstatus_managers
        self.webhook_bots = config.webhook_bots
        self.preload_ext = config.preload_extensions

        kwargs["command_prefix"] = prefix_manager
        kwargs["pm_help"] = True
        # kwargs["command_prefix"] = self.db.prefix_manager
        kwargs["help_command"] = DefaultHelpCommand(dm_help=config.dm_only)
        kwargs["owner_id"] = self.owner
        super().__init__(**kwargs)
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.esi_data = ESI(self.session)
        self.loop.create_task(self.load_db())
示例#2
0
 def configure_bot(self):
     hc = DefaultHelpCommand(command_attrs={'name': 'nice-help'})
     bot = Bot(command_prefix='!', help_command=hc)
     cogs = [
         Listeners(bot, self.dp, self.config['bot']),
         Commands(bot, self.dp)
     ]
     for cog in cogs:
         bot.add_cog(cog)
     self.bot = bot
示例#3
0
 def __init__(self):
     super().__init__("!", DefaultHelpCommand(dm_help=True), BOT_DESCRIPTION, intents=INTENTS)
     self.on_initialized: EventHook = EventHook()
     self.on_user_joined: EventHook = EventHook()
     self.on_user_update: EventHook = EventHook()
     self.on_user_remove: EventHook = EventHook()
     self.on_user_message: EventHook = EventHook()
     self.ADMIN_USER: BunkUser = None
     self.server: Guild = None
     self.member_ref: Member
     self.name: str = None
     self.name_lower: str = None
示例#4
0
    def __init__(self,
                 command_prefix,
                 help_command=None,
                 description=None,
                 **options):

        if help_command is None:
            help_command = DefaultHelpCommand()

        super().__init__(command_prefix,
                         help_command=help_command,
                         description=description,
                         **options)
示例#5
0
    def __init__(self,
                 command_prefix,
                 log_channel_id=None,
                 help_command=DefaultHelpCommand(),
                 description=None,
                 **options):
        super().__init__(command_prefix=command_prefix,
                         help_command=help_command,
                         description=description,
                         **options)
        self.log_channel_id = log_channel_id
        self.library = CogLib(self)

        self.api = None
示例#6
0
 def __init__(self):
     super().__init__(
         command_prefix=get_config("prefix"),
         description="Bot to monitor uptime of services",
         reconnect=True,
         intents=discord.Intents.default(),
         activity=discord.Activity(
             type=getattr(discord.ActivityType,
                          get_config("activity_type").lower()),
             name="services",
         ),
         help_command=DefaultHelpCommand()
         if not get_config("disable_help") == "true" else None,
     )
     self.bot = bot
示例#7
0
    def __init__(self,
                 command_prefix,
                 help_command=DefaultHelpCommand(),
                 description=None,
                 **kwargs):
        self.command_prefix = command_prefix
        self.extra_events = {}
        self._BotBase__cogs = {}
        self._BotBase__extensions = {}
        self._checks = []
        self._check_once = []
        self._before_invoke = None
        self._after_invoke = None
        self._help_command = None
        self.description = inspect.cleandoc(description) if description else ""
        self.owner_id = kwargs.get("owner_id")
        self.owner_ids = kwargs.get("owner_ids", set())
        self._skip_check = lambda x, y: x == y
        self.help_command = help_command
        self.case_insensitive = kwargs.get("case_insensitive", False)
        self.all_commands = _CaseInsensitiveDict(
        ) if self.case_insensitive else {}

        self.ws = None
        self.loop = asyncio.get_event_loop()
        self.http = HTTPClient(None, loop=self.loop)

        self._handlers = {"ready": self._handle_ready}
        self._hooks = {}
        self._listeners = {}

        self._connection = None
        self._closed = False
        self._ready = asyncio.Event()

        self._redis = None
        self._amqp = None
        self._amqp_channel = None
        self._amqp_queue = None
示例#8
0
logger.setLevel(
    logging.INFO
)  # logging levels: NOTSET (all), DEBUG (bot interactions), INFO (bot connected etc)
handler = logging.FileHandler(filename='discord.log',
                              encoding='utf-8',
                              mode='w')
handler.setFormatter(
    logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)

# load the private discord token from .env file.
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

# Initialise the Bot object with an accessible help Command object
helpCommand = DefaultHelpCommand()

bot = commands.Bot(command_prefix=".", help_command=helpCommand)

# Setup the General cog with the help command
generalCog = Utilities()
bot.add_cog(generalCog)
helpCommand.cog = generalCog

# Define list of morning response triggering substrings
morningTriggers = {
    "morn": "Good morning from",
    "gninrom": "morf gninrom dooG",
    # Brythonic
    "bore": "Bore da o",
    "myttin": "Myttin da diworth",
示例#9
0
 def cog_unload(self):
     self.client.get_command('help').hidden = False
     self.client.help_command = DefaultHelpCommand()
示例#10
0
文件: helpall.py 项目: SirDagen/felix
 def cog_unload(self):
     self.client.help_command = DefaultHelpCommand()
示例#11
0
        except SystemExit:
            await bot.send("I tried to quit().")
        finally:
            sys.stdout = old_stdout
        output = redirected_output.getvalue()
        output = "No output." if not output else output
        await bot.send(output)


if __name__ == "__main__":

    intents = discord.Intents.default()
    intents.members = True

    if "--debug" in argv:
        bot = commands.Bot(command_prefix=['##', 'feubeta '], description='this is feubot beta.', intents=intents, help_command = DefaultHelpCommand(dm_help=True))
    else:
        bot = commands.Bot(command_prefix=['!', '>>', 'feubot '], description='this is feubot.', intents=intents, help_command = DefaultHelpCommand(dm_help=True))

    @bot.event
    async def on_ready():
        print('Logged in as')
        print(bot.user.name)
        print(bot.user.id)
        print('------')
        await bot.change_presence(activity=discord.Game(name="Reading the doc!"))

    @bot.event
    async def on_raw_reaction_add(payload):
        messageID = payload.message_id
        reaction  = payload.emoji.name
示例#12
0
from datetime import datetime
from discord import Member, Message, Reaction, Role, TextChannel, User
from discord.ext.commands import Bot, CommandInvokeError, DefaultHelpCommand, Context, Converter, Greedy
from emoji import get_emoji_regexp
from os import environ
from re import compile, findall, UNICODE
from typing import Union

from .cogs import BirthdayManager, EventsManager, ImpersonateManager, PollManager, RolesManager, RollManager, StatsManager, StatusManager
from .util import redis

__all__ = ["bot"]

bot = Bot(command_prefix='>', help_command=DefaultHelpCommand(dm_help=True))

bot.add_cog(BirthdayManager(bot))
bot.add_cog(EventsManager(bot))
bot.add_cog(ImpersonateManager(bot))
bot.add_cog(PollManager(bot))
bot.add_cog(RolesManager(bot))
bot.add_cog(RollManager(bot))
bot.add_cog(StatsManager(bot))
bot.add_cog(StatusManager(bot))

discord_emojis = r'<a?:[a-zA-Z0-9\_]+:[0-9]+>'

unicode_emojis = get_emoji_regexp()


@bot.event
async def on_message(message: Message):
示例#13
0
def teardown(bot) -> None:
    bot.help_command = DefaultHelpCommand()