-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
99 lines (78 loc) · 2.94 KB
/
main.py
File metadata and controls
99 lines (78 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import asyncio
import asyncpraw
from asyncpraw import Reddit
import discord
import json
import random
from discord.ext import commands, tasks
from discord.commands import slash_command
from itertools import cycle
from discord.utils import get
import typing
import datetime
import os
import traceback
import sys
import discordmongo
import motor.motor_asyncio
from discord import Spotify
import PycordUtils
from dotenv import load_dotenv
import json
import requests
class ModifiedMinimalHelpCommand(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
for page in self.paginator.pages:
emby = discord.Embed(description=page, colour = discord.Colour.og_blurple())
await destination.send(embed=emby)
# Prefix Function
async def get_prefix(bot, message):
if not message.guild:
return commands.when_mentioned_or(bot.prefix)(bot, message)
try:
data = await bot.prefixes.find(message.guild.id)
if not data or "prefix" not in data:
return commands.when_mentioned_or(bot.prefix)(bot, message)
return commands.when_mentioned_or(data["prefix"])(bot, message)
except:
return commands.when_mentioned_or(data["prefix"])(bot, message)
# Bot Variables
intents = discord.Intents.all()
bot = commands.Bot(command_prefix = get_prefix, intents=intents, case_insensitive=True)
load_dotenv(dotenv_path="./.env")
bot.help_command = ModifiedMinimalHelpCommand()
bot.prefix = os.getenv('PREFIX')
bot.version = '3.5.22'
bot.invite_link = os.getenv('INVITE_LINK')
bot.bot_ids = [872558551573348392, 678863504991584256]
bot.ow_api_key = os.getenv('OW_API_KEY')
bot.sniped_messages = {}
MONGO_CONNECTION = os.getenv('MONGO_CONNECTION')
bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(MONGO_CONNECTION)
bot.db_prefix = bot.mongo["Prefixes"]
bot.db_log = bot.mongo["Log_Channels"]
bot.db_mute = bot.mongo["Mute_Roles"]
bot.prefixes = discordmongo.Mongo(connection_url=bot.db_prefix, dbname="Prefixes")
bot.log_channels = discordmongo.Mongo(connection_url=bot.db_log, dbname="Log_Channels")
bot.mute_roles = discordmongo.Mongo(connection_url=bot.db_log, dbname="Mute_Roles")
bot.main_color = discord.Colour.blue()
bot.utils_color = discord.Colour.og_blurple()
bot.logging_color = discord.Colour.red()
bot.mod_color = discord.Colour.dark_red()
bot.api_color = discord.Colour.orange()
bot.error_color = discord.Colour.dark_orange()
@tasks.loop(seconds=300.0)
async def presence_update():
guild_count = len(bot.guilds)
await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'{bot.prefix}help | Serving {guild_count} guilds.'))
@presence_update.before_loop
async def before_presence_update():
await bot.wait_until_ready()
presence_update.start()
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
# Running The Bot
BOT_TOKEN = os.getenv('BOT_TOKEN')
bot.run(BOT_TOKEN)