def __init__(self): self.PREFIX = PREFIX self.ready = False self.guild = None self.schedulers = AsyncIOScheduler() super().__init__(command_prefix=PREFIX, owner_ids=OWNER_IDS, Intents=Intents.all())
def __init__(self, _printHandler: PrintHandler): super().__init__(Intents.all()) system('clear') self.printHandler = _printHandler self.printHandler.info("Initialisation du bot...") self.prefix = config["BOT"].get("prefix", "!") # We need to load extensions from config file self.printHandler.info("Chargement des extensions...") extensions = list(map(lambda extension: extension.replace(fileDelimiter, ".")[:-3], glob("extensions/*.py"))) for index, _ in enumerate(self.load_extensions(extensions)): self.printHandler.info(f"Chargement réussi de " f"{Colors.light_magenta.value + extensions[index].replace('extensions.', '')}")
def create_bot(env: Env, session: aiohttp.ClientSession) -> Bot: """ Setup the Bot """ intents = Intents.default() intents.members = True bot = Rollo(("!", "?", "->"), intents=intents) async def on_ready(): LOGGER.info("Logged in as %s: %d", bot.user.name, bot.user.id) async def on_command_error(_, error): LOGGER.warning("Command error: %s", error) bot.add_listener(on_ready, "on_ready") bot.add_listener(on_command_error, "on_command_error") bot.add_cog(General(bot)) bot.add_cog(Meiern()) if env.str("TENOR_TOKEN", None) is not None: LOGGER.info("Tenor API Key found. Enabling GIF posting!") bot.add_cog(Memes(session, env.str("TENOR_TOKEN"))) return bot
from dotenv import load_dotenv from discord.ext import commands from cogs.roles import Roles from cogs.tags import Tags from cogs.stats import Stats from cogs.misc import Misc from cogs.moderation import Moderation from cogs.music import Music from cogs.weather import Weather from cogs.blacklist import Blacklist load_dotenv() run = asyncio.get_event_loop().run_until_complete bot = commands.Bot(command_prefix='?', intents=Intents.all()) bot.pool = run(asyncpg.create_pool(os.getenv('DATABASE_URL'))) bot.add_cog(Roles(bot)) bot.add_cog(Tags(bot)) bot.add_cog(Stats(bot)) bot.add_cog(Misc(bot)) bot.add_cog(Moderation(bot)) bot.add_cog(Music(bot)) bot.add_cog(Weather(bot, os.getenv('WEATHER_TOKEN'))) bot.add_cog(Blacklist(bot)) @bot.event async def on_ready(): print(f'{bot.user.name} ready') @bot.event
def __init__(self): self.PREFIX = PREFIX super().__init__(command_prefix=PREFIX, OWNER_IDS=OWNER_IDS, intents=Intents.all(), help_command=None)
# SQL stuffs from core.dao import engin from core.model import initialize_sql, DBSession from core.model.server import Server # Import cogs from cogs.games import Games from cogs.roger.roger import Roger from cogs.youtube import NFYouTube from cogs.ggl_img import NFGoogleImg # Bot configuration bot = commands.Bot(command_prefix=["nf ", '\\'], owner_id=nf_configs['owner_id'], intents=Intents(messages=True, guilds=True, members=True, presences=True)) initialize_sql(engin) # Cogs bot.add_cog(Games(bot, 1)) bot.add_cog(Roger(bot, 2)) bot.add_cog(NFYouTube(bot, 4)) bot.add_cog(NFGoogleImg(bot, 8)) # Bot events @bot.event async def on_command_error(ctx, error): # this one is just so the logs don't get polluted with
import inspect from discord.utils import get import youtube_dl from pretty_help import PrettyHelp from cogwatch import Watcher from cmds.feedback import create_feedback, list_feedback, delete_feedback from cmds.ytactivity import group_say from log import log l = log() bot = commands.Bot(command_prefix="\\", intents=Intents.all(), case_insensitive=True) slash = SlashCommand(bot, sync_commands=True, sync_on_cog_reload=True) servers = len(bot.guilds) status = cycle([ '\\help', 'your messages', '\\help', 'Never Gonna Give You Up', '\\help', 'hello there!', '\\help', f'{servers} servers' ]) guild_ids = [824862561328562176] @bot.event async def on_ready(): change_status.start() l.log(f'We have logged in as {bot.user}')
from app.database import Database import os import discord from dotenv import load_dotenv from discord.ext import commands from app.mc_client import McClient load_dotenv() EXTENSIONS = [ "app.cogs.manage", "app.cogs.player", "jishaku", ] INTENTS: Intents = Intents.default() INTENTS.members = True class CCBot(commands.Bot): def __init__(self): super().__init__(command_prefix="cc!", case_insensitive=True, allowed_mentions=AllowedMentions.none(), intents=INTENTS, activity=discord.Activity( type=discord.ActivityType.watching, name="People play CircuitCraft")) self.logging_hook = discord.Webhook.from_url( os.getenv("WEBHOOK"), adapter=discord.RequestsWebhookAdapter())
if message.author.bot: return ctx = await self.get_context(message) await self.invoke(ctx) def start_bot(self): """ CONNECT TO WEBSOCKET AND LOAD COGS """ self.loop.run_until_complete(self.start_CFL()) self.run(self.token) # CONFIGURE INTENTS intents = Intents.default() intents.members = True # INSTANTIATE BOT bot_args = { "owner_ids": [448359781095440385, 707876147324518440], "intents": intents, "help_command": None, "case_insensitive": True, "token": config("TOKEN") } bot = Symbion(**bot_args) # LOAD A NEW COG @bot.command(name="load", help="Load a cog into the bot.", hidden=True)
from discord.ext import commands from discord.flags import Intents from discord_slash import SlashCommand from discord_slash.utils.manage_commands import create_option from logger.logger import log from util.directory_util import create_directory from env.env_loader import load_env import env.hassan_env as hassan_env from favorite import favorite_controller from cache import cache_controller from util.string_util import combine_words from dccon import dccon_controller from view import help, console, error bot = commands.Bot(command_prefix='!', intents=Intents.default()) slash = SlashCommand(bot, sync_commands=True) load_env() @bot.event async def on_ready(): await bot.change_presence(activity=Game(name='!도움')) console.print_on_ready() @slash.slash(name="도움", description="도움말을 볼 수 있습니다.", options=[]) async def slash_help(ctx): await help.send_help(ctx)
def intents(**kwargs): out = Intents.default() for k, v in kwargs.items(): setattr(out, k, v) return out