async def run(): help_attrs = dict(hidden=True) credentials = { "user": config.dbname, "password": config.dbpass, "database": config.database, "host": "127.0.0.1", } db = await asyncpg.create_pool(**credentials) await db.execute( "CREATE TABLE IF NOT EXISTS warnings(userid bigint, warnings int);") await db.execute( "CREATE TABLE IF NOT EXISTS artstats(userid bigint, upvotes int);") await db.execute( "CREATE TABLE IF NOT EXISTS sketchdaily(code int, artist varchar, idea varchar);" ) bot = Bot( command_prefix=config.prefix, prefix=config.prefix, pm_help=True, help_attrs=help_attrs, formatter=HelpFormat(), db=db, ) try: print("Logging in...") for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") await bot.start(config.token) except KeyboardInterrupt: await db.close() await bot.logout()
async def run(): # Create a Dictionary under the name help attrs help_attrs = dict(hidden=True) # Log into the database credentials = { "user": config.dbname, "password": config.dbpass, "database": config.database, "host": "127.0.0.1", } db = await asyncpg.create_pool(**credentials) # Add tables if they don't exist await db.execute( "CREATE TABLE IF NOT EXISTS warnings(serverid bigint, userid bigint, warnings int);" ) await db.execute( "CREATE TABLE IF NOT EXISTS modlogs(serverid bigint, caseid bigint, casenumber int, casetype varchar, target bigint, moderator bigint, reason varchar);" ) await db.execute( "CREATE TABLE IF NOT EXISTS adminpanel(serverid bigint, joins int, leaves int, embeds int, nsfw int, automod int, modlog int);" ) await db.execute( "CREATE TABLE IF NOT EXISTS automod(serverid bigint, autorole int, adblock int, lockdown int, antispam int, owo int, uwu int, ignorerole int, actionlog int);" ) await db.execute( "CREATE TABLE IF NOT EXISTS idstore(serverid bigint, joinmsg varchar, leavemsg varchar, joinchan bigint, leavechan bigint, modlogchan bigint, ignorerolerole bigint, autorolerole bigint, actionlogchan bigint);" ) await db.execute( "CREATE TABLE IF NOT EXISTS tags(serverid bigint, tagname varchar, tagtext varchar);" ) await db.execute( "CREATE TABLE IF NOT EXISTS userbal(userid bigint, money bigint);") # Make the client bot = Bot(command_prefix=config.prefix, pm_help=True, help_attrs=help_attrs, db=db) # Remove help command bot.remove_command("help") # Get the cogs, send a startup message try: print("Logging in...") for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") await bot.start(config.token) except KeyboardInterrupt: await db.close() await bot.logout()
from discord.ext.commands import HelpFormatter from data import Bot from utils import permissions, default config = default.get("config.json") description = """ Project Management Bot Made by Johan Tan based on starter bot code by AlexFlipnote """ class HelpFormat(HelpFormatter): async def format_help_for(self, context, command_or_bot): if permissions.can_react(context): await context.message.add_reaction(chr(0x2709)) return await super().format_help_for(context, command_or_bot) print("Logging in...") help_attrs = dict(hidden=True) bot = Bot(command_prefix=config.prefix, prefix=config.prefix, pm_help=True, help_attrs=help_attrs, formatter=HelpFormat()) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(config.discord_token)
from data import Bot from utils import permissions, default from utils.data import Bot, HelpFormat from datetime import datetime client = discord.Client() intents = discord.Intents.all() config = default.get("config.json") description = """ F**k me - Ahiga - AKA Big C**k Hammer- AKA Drunk f*****g sad lowlife - AKA Big chief. """ bot = Bot( command_prefix=config.prefix, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat(), message_list = {} intents = intents ) print("Purging fags...") #bot = Bot(command_prefix=config.prefix, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat()) bot.startup = datetime.now() for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(config.token)
async def send_command_help(self, command): self.add_command_formatting(command) self.paginator.close_page() await self.send_pages(no_pm=True) async def send_pages(self, no_pm: bool = False): try: if permissions.can_react(self.context): await self.context.message.add_reaction(chr(0x2709)) except discord.Forbidden: pass try: destination = self.get_destination(no_pm=no_pm) for page in self.paginator.pages: await destination.send(page) except discord.Forbidden: destination = self.get_destination(no_pm=True) await destination.send("Couldn't send help to you due to blocked DMs...") print("Logging in...") bot = Bot(command_prefix=config.prefix, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat()) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(config.token)
if len(config.tokens) != 2: print("Only 2 bot tokens is acceptable at this current time.\n" f"You currently have {len(config.tokens)} listed in config.json") sys.exit() print("Logging in...\n------------------------------") stats.reset_stats() def prefixer(bot, message): return [f"<@!{bot.user.id}> ", f"<@{bot.user.id}> "] for g in config.tokens: bot = Bot(command_prefix=prefixer, prefix=prefixer, pm_help=True, help_attrs=dict(hidden=True)) bot.startup = datetime.now() for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") tasks.append(loop.create_task(bot.start(g))) try: loop.run_until_complete(asyncio.gather(*tasks)) except KeyboardInterrupt: print("CTRL + C was pressed, closing asyncio...") loop.close() except asyncio.CancelledError:
from discord.ext.commands import HelpFormatter from data import Bot from utils import permissions, default from discord import Webhook, AsyncWebhookAdapter import aiohttp config = default.get("config.json") description = """ A simple starter bot code Made by AlexFlipnote """ print("-w- zzz...") bot = Bot(command_prefix=os.environ["PREFIX"] + " ", prefix=os.environ["PREFIX"] + " ", pm_help=True) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] try: bot.load_extension(f"cogs.{name}") except Exception as e: print(type(e).__name__) print(f"{e}") print(f"\nFailed to load {name}") pass bot.run(os.environ["TOKEN"])
if permissions.can_react(context): await context.message.add_reaction(chr(0x2705)) return await super().format_help_for(context, command_or_bot) help_attrs = dict(hidden=True) with open("config.json") as f: data = json.load(f) token = data["token"] prefix = data["prefix"] description = """ Terminal.py, a bot that is made to be used in terminal server """ bot = Bot(command_prefix=prefix, prefix=prefix, description=description, pm_help=True, help_attrs=help_attrs, formatter=HelpFormat()) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(token)
import discord from discord.ext import commands from data import Bot bot = Bot(command_prefix=commands.when_mentioned_or("uwu "), prefix=commands.when_mentioned_or("uwu "), pm_help=True) @bot.event async def on_message_delete(message): author = author chan = bot.get_channel(453991541434744832) await chan.send("Message from {author} deleted\n```{message}```")