Example #1
0
def entrypoint(token: str):
    """
    Entrypoint accessible through `python -m jishaku <TOKEN>`
    """

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    logger.addHandler(LOG_STREAM)

    bot = commands.Bot(commands.when_mentioned)
    bot.load_extension('jishaku')
    bot.run(token)
Example #2
0
is_initialized = False

intents = Intents.none()
intents.guilds = True
intents.members = True
intents.emojis = True
intents.messages = True
intents.message_content = True
intents.reactions = True
intents.presences = True

bot = commands.Bot(
    command_prefix=commands.when_mentioned_or(*config.command_prefix),
    help_command=None,
    case_insensitive=True,
    allowed_mentions=AllowedMentions(roles=False, everyone=False, users=True),
    intents=intents,
)

presence = presence.Presence(bot)


@bot.event
async def on_ready():
    """If RubberGod is ready"""
    # Inspirated from https://github.com/sinus-x/rubbergoddess/blob/master/rubbergoddess.py
    global is_initialized
    if is_initialized:
        return
    is_initialized = True
Example #3
0
            if not guild:
                self.add_button("В начало", "link", "root")

    def add_button(self, name, action, link=None):
        self.add_item(
            MenuButton(name=name, action=action, link=link, row=self.__row))
        self.__col += 1
        if self.__col > 4:
            self.__col = 1
            self.__row += 1


#test_guilds = [716373583982493697]
test_guilds = None
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'),
                   sync_commands_debug=True,
                   test_guilds=test_guilds)


@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')
    for guild in bot.guilds:
        print(f' ` joined to guild {guild.id} ({guild.name})')


@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.author.bot:
Example #4
0
from typing import List

import disnake
from disnake.ext import commands

from bots import imps

bot = commands.Bot()


class Menu(disnake.ui.View):
    def __init__(self, embeds: List[disnake.Embed],
                 options: List[disnake.SelectOption]):
        super().__init__(timeout=None)

        # Sets the embed list variable.
        self.embeds = embeds
        self.options = options

        # Current embed number.
        self.embed_count = 0

        # Disables previous page button by default.
        self.prev_page.disabled = True

        # Sets the footer of the embeds with their respective page numbers.
        self.count = 0
        self.set_link_button()

        for opt in options:
            self.selector.append_option(opt)  # pylint: disable=E1101
Example #5
0
from controllers import SlashController
from controllers import PrefixController

DiscordContext = commands.Context

log = LogService()
service = CollageService(log)
slash_controller = SlashController(service, log)
prefix_controller = PrefixController(service, log)

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

bot = commands.Bot(command_prefix=PREFIX,
                   test_guilds=TEST_GUILDS,
                   intents=intents)

# i hate that i have to do this
prefix_controller.set_user(bot.user)


### SLASH COMMANDS ###
@bot.slash_command(name="ping")
async def _ping(inter: ApplicationCommandInteraction):
    await inter.response.send_message(
        content="Pong! ({}ms)".format(bot.latency * 1000))


@bot.slash_command(
    name="collage",
# Logging
formatter = logging.Formatter('%(asctime)s [%(levelname)s]: %(message)s')
handler = logging.FileHandler('bot.log')
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.setLevel(logging.INFO)

# Intents
intents = disnake.Intents.default()
intents.messages = True

bot_command_prefix = 'schedule'
bot = commands.Bot(command_prefix=f'!{bot_command_prefix} ',
                   help_command=None,
                   intents=intents)


@bot.event
async def on_ready():
    for guild in bot.guilds:
        logger.info(
            f'Logged into server: "{guild.name}" (id: {guild.id}, members: {guild.member_count})'
        )
    await bot.change_presence(
        activity=disnake.Activity(type=disnake.ActivityType.listening,
                                  name=f"!{bot_command_prefix} help"))


@bot.event
Example #7
0
File: code.py Project: D-9341/Bot
import datetime
import os
import re
import random

import disnake
from pathlib import Path
from pymongo import MongoClient
from disnake.ext import commands
from disnake.utils import get

client = commands.Bot(command_prefix=commands.when_mentioned_or('cy/'),
                      intents=disnake.Intents.all(),
                      owner_id=338714886001524737,
                      status=disnake.Status.idle,
                      activity=disnake.Activity(
                          type=disnake.ActivityType.watching,
                          name='Чё там у хохлов'),
                      allowed_mentions=disnake.AllowedMentions(everyone=False),
                      case_insensitive=True)
client.remove_command('help')
passw = os.environ.get('passw')
cluster = MongoClient(
    f"mongodb+srv://cephalon:{passw}@locale.ttokw.mongodb.net/Locale?retryWrites=true&w=majority"
)
collection = cluster.Locale.locale
cwd = Path(__file__).parents[0]
cwd = str(cwd)


@client.event