def main(): config = default.get_from_env("CONFIG") if config is None: exit(3) print("機器人登入中 ...") 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}") token = os.environ.get("TOKEN") if token is None: exit(2) bot.run(token)
import os import discord from utils import default from utils.data import Bot, HelpFormat config = default.config() print("Logging in...") bot = Bot( command_prefix=config["prefix"], prefix=config["prefix"], owner_ids=config["owners"], command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=discord.Intents( # kwargs found at https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents guilds=True, members=True, messages=True, reactions=True, presences=True ) ) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") try: bot.run(config["token"]) except Exception as e: print(f'Error when logging in: {e}')
from utils import default from utils.data import Bot, HelpFormat config = default.config() print("Logging in...") bot = Bot( command_prefix=config["prefix"], prefix=config["prefix"], owner_ids=config["owners"], command_attrs=dict(hidden=True), help_command=HelpFormat(), allowed_mentions=discord.AllowedMentions(roles=False, users=True, everyone=False), intents=discord. Intents( # kwargs found at https://docs.pycord.dev/en/master/api.html?highlight=discord%20intents#discord.Intents guilds=True, members=True, messages=True, reactions=True, presences=True, message_content=True, )) try: bot.run(config["token"]) except Exception as e: print(f"Error when logging in: {e}")
import os from utils import default from utils.data import Bot, HelpFormat config = default.get("config.json") 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)
import os from utils import default from utils.data import Bot, HelpFormat config = default.get("config.json") 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(os.environ['DISCORD_TOKEN'])
config_json = False try: import config except ImportError: if os.environ.get('config'): raise ImportError("Can not load config") import json config = json.dumps(os.environ.get('config')) config_json = True print("Logging in...") bot = Bot( command_prefix=config.PREFIX, prefix=config.PREFIX, owner_ids=config.OWNERS, command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=discord.Intents( # kwargs found at https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents guilds=True, members=True, messages=True, reactions=True, presences=True ) ) for file in os.listdir("cogs"): if file.endswith(".py"): bot.load_extension(f"cogs.{file[:-3]}") try: bot.run(config['token'] if config_json else config.TOKEN) except Exception as e: print(f'Error when logging in:\n{e}')
from utils.data import Bot from config import config from musicbot.audiocontroller import AudioController from musicbot import utils from musicbot.utils import guild_to_audiocontroller from musicbot.commands.general import General initial_extensions = ['musicbot.commands.music', 'musicbot.commands.general', 'musicbot.button'] print("Logging in...") bot = Bot( command_prefix='kek ', prefix='kek ', command_attrs=dict(hidden=True), ) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") for extension in initial_extensions: try: bot.load_extension(extension) except Exception as e: print(e) try:
import os import discord from utils import default from utils.data import Bot, HelpFormat config = default.get("config.json") print("Logging in...") bot = Bot( command_prefix=config.prefix, prefix=config.prefix, owner_ids=config.owners, command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=discord. Intents( # kwargs found at https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents guilds=True, members=True, messages=True, reactions=True)) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") try: bot.run('Nzc0Nzg0ODk5MDU1NDg0OTkw.X6c0qg.bJkR3ZWo7PuQx3MLyN0skgoQE28') except Exception as e: print(f'Error when logging in: {e}')
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from utils.data import Bot, HelpFormat from utils.default import get cfg = get("config.json") bot = Bot(command_prefix=cfg.prefix, prefix=cfg.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat(), case_insensitive=True) bot.run(cfg.token)
import os import discord from utils import default from utils.data import Bot, HelpFormat config = default.get("config.json") print("Logging in...") bot = Bot(command_prefix=config.prefix, owner_ids=config.owners, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=discord.Intents(members=True)) # see more about intents here: https://discordpy.readthedocs.io/en/latest/intents.html for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") try: bot.run(config.token) except Exception as e: print(f'Error when logging in: {e}')
import os import discord from dotenv import load_dotenv from utils.data import Bot, HelpFormat load_dotenv() TOKEN = os.getenv("DISCORD_TOKEN") intents = discord.Intents.default() intents.members = True bot = Bot(command_prefix=os.getenv("PREFIX"), prefix=os.getenv("PREFIX"), command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=intents) for file in os.listdir("commands"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"commands.{name}") try: bot.run(TOKEN) except Exception as e: print(f'Error when logging in: {e}')
import discord from utils import default from utils.data import Bot, HelpFormat from utils.serverdata import ServerData config = default.get("config.json") token = default.get("token.json") print("Logging in...") intents = discord.Intents.default() intents.reactions = True intents.members = True helper = HelpFormat() bot = Bot(command_prefix=config.prefix, intents=intents, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=helper) bot.server_data = ServerData(bot) for file in os.listdir("cogs"): if file.endswith(".py") and not '__init__' in file: name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(token.t1 + token.t2)
import logging import discord import os from configparser import ConfigParser from utils import default from utils.data import Bot config = default.get("config.json") logging.basicConfig(filename="latest.log", level=logging.DEBUG, filemode="w", format="[ %(asctime)s: ] %(levelname)s: %(message)s", datefmt="%d/%m/%Y %I:%M:%S %p") bot = Bot(command_prefix=config.prefix, prefix=config.prefix) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") bot.run(config.token)