Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

started implementation of vars.py #196

Merged
merged 3 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
TOKEN =
SENTRY =
eitozx marked this conversation as resolved.
Show resolved Hide resolved
CHATBOTTOKEN =
DAGPI =
STATCORD =


DISCORDBOTLIST =
DISCORDBOTSGG =
TOPGG =
BOTSFORDISCORD =
BOTLISTSPACE =
DISCORDBOATS =
VOIDBOT =
FATESLIST =
BLADEBOT =
SPACEBOT =
DISCORDLABS =
INFINITY =


WEBSITE =
GITHUB =
VERSION =
4 changes: 2 additions & 2 deletions minato_namikaze/bot_files/lib/classes/select_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect
from .time_class import *
from .paginator import *
from ..util import github
from ..util import LinksAndVars


class GroupHelpPageSource(menus.ListPageSource):
Expand Down Expand Up @@ -120,7 +120,7 @@ def format_page(self, menu: HelpMenu, page):
":pray: Konichiwa :pray:, myself **Minato Namikaze**, **Konohagakure <:uzumaki_naruto:874930645405675521> Yondaime Hokage**"
f'I joined discord on {created_at}. I try my best to do every work of a **hokage**. You can get more '
'information on my commands by using the *dropdown* below.\n\n'
f"I'm also open source. You can see my code on [GitHub]({github})!"
f"I'm also open source. You can see my code on [GitHub]({LinksAndVars.github.value})!"
),
inline=False,
)
Expand Down
5 changes: 3 additions & 2 deletions minato_namikaze/bot_files/lib/classes/setup/ban.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import discord
from discord.ext import menus

from ...util import ban
from ...util import SetupVars
from ..embed import Embed

ban = SetupVars.ban.value

class Ban(menus.Menu):
def __init__(self, bot, timeout, channel):
Expand All @@ -28,7 +29,7 @@ async def on_add(self, payload):
)
ban_channel = await self.ctx.guild.create_text_channel(
"ban",
topic=ban,
topic = ban,
overwrites={self.ctx.guild.default_role: discord.PermissionOverwrite(
read_messages=False, send_messages=False)},
category=discord.utils.get(
Expand Down
4 changes: 2 additions & 2 deletions minato_namikaze/bot_files/lib/classes/setup/feedback.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import discord
from discord.ext import menus

from ...util import feedback
from ...util import SetupVars
from ..embed import Embed


Expand All @@ -22,7 +22,7 @@ async def send_initial_message(self, ctx, channel):
async def on_add(self, payload):
feed = await self.ctx.guild.create_text_channel(
"Feedback",
topic=feedback,
topic = SetupVars.feedback.value,
overwrites={self.ctx.guild.default_role: discord.PermissionOverwrite(
read_messages=False, send_messages=False)},
category=discord.utils.get(
Expand Down
4 changes: 2 additions & 2 deletions minato_namikaze/bot_files/lib/classes/setup/support.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import discord
from discord.ext import menus

from ...util import perms_dict, support
from ...util import perms_dict, SetupVars
from ..embed import Embed


Expand Down Expand Up @@ -38,7 +38,7 @@ async def on_add(self, payload):

sup = await self.ctx.guild.create_text_channel(
"Support", overwrites=overwrite_dict,
topic=support,
topic = SetupVars.support.value,
category=discord.utils.get(
self.ctx.guild.categories, name="Admin / Feedback")
)
Expand Down
4 changes: 2 additions & 2 deletions minato_namikaze/bot_files/lib/classes/setup/unban.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import discord
from discord.ext import menus

from ...util import unban as unbantopic
from ...util import SetupVars
from ..embed import Embed


Expand Down Expand Up @@ -31,7 +31,7 @@ async def on_add(self, payload):
"unban",
overwrites={self.ctx.guild.default_role: discord.PermissionOverwrite(
read_messages=False, send_messages=False)},
topic=unbantopic,
topic= SetupVars.unban.value,
category=discord.utils.get(
self.ctx.guild.categories,
name="Bingo Book")
Expand Down
4 changes: 2 additions & 2 deletions minato_namikaze/bot_files/lib/classes/setup/warns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import discord
from discord.ext import menus

from ...util import warns
from ...util import SetupVars
from ..embed import Embed


Expand Down Expand Up @@ -29,7 +29,7 @@ async def on_add(self, payload):
)
unban = await self.ctx.guild.create_text_channel(
"warns",
topic=warns,
topic = SetupVars.warns.value,
overwrites={self.ctx.guild.default_role: discord.PermissionOverwrite(
read_messages=False, send_messages=False)},
category=discord.utils.get(
Expand Down
22 changes: 11 additions & 11 deletions minato_namikaze/bot_files/lib/functions/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,60 @@
from discord.ext import commands

from ..classes import ErrorEmbed
from ..util import ban, feedback, support, unban, warns
from ..util import SetupVars


#checks warns
def check_if_warning_system_setup(ctx):
if discord.utils.get(ctx.guild.text_channels, topic=warns):
if discord.utils.get(ctx.guild.text_channels, topic = SetupVars.warns.value):
return True
else:
return False

#checks support
def check_if_support_is_setup(ctx):
if discord.utils.get(ctx.guild.text_channels, topic=support):
if discord.utils.get(ctx.guild.text_channels, topic = SetupVars.support.value):
support_channel = True
else:
support_channel = False
return support_channel

#checks ban
def check_if_ban_channel_setup(ctx):
if discord.utils.get(ctx.guild.text_channels, topic=ban):
if discord.utils.get(ctx.guild.text_channels, topic = SetupVars.ban.value):
return True
else:
return False

#checks unban
def check_if_unban_channel_setup(ctx):
if discord.utils.get(ctx.guild.text_channels, topic=unban):
if discord.utils.get(ctx.guild.text_channels, topic = SetupVars.unban.value):
return True
else:
return False

#check feedback
def check_if_feedback_system_setup(ctx):
if discord.utils.get(ctx.guild.text_channels, topic=feedback):
if discord.utils.get(ctx.guild.text_channels, topic = SetupVars.feedback.value):
return True
else:
return False

#return warns
def return_warning_channel(ctx = None, guild = None):
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic=warns)
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic = SetupVars.warns.value)

def return_ban_channel(ctx = None, guild = None):
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic=ban)
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic = SetupVars.ban.value)

def return_unban_channel(ctx = None, guild = None):
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic=unban)
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic = SetupVars.unban.value)

def return_feedback_channel(ctx = None, guild = None):
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic=feedback)
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic = SetupVars.feedback.value)

def return_support_channel(ctx = None, guild = None):
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic=support)
return discord.utils.get(ctx.guild.text_channels if ctx else guild.text_channels, topic = SetupVars.support.value)



Expand Down
34 changes: 19 additions & 15 deletions minato_namikaze/discordbot.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
from discord.ext import commands
import ast
import os
import ast
import time
from os.path import join
from pathlib import Path
import discord
import dotenv
import discord
import logging
import sentry_sdk
from pathlib import Path
from os.path import join
from discord.utils import format_dt
from discord.ext import commands
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
from sentry_sdk.integrations.threading import ThreadingIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.modules import ModulesIntegration

from bot_files.lib import var, Embed
from bot_files.lib import Tokens, Embed, PostStats

logger = logging.getLogger(__name__)
log = logging.getLogger(__name__)


dotenv_file = os.path.join(Path(__file__).resolve().parent.parent / ".env")
Expand Down Expand Up @@ -54,7 +60,7 @@ def __init__(self):

super().__init__(
command_prefix=self.get_prefix,
description=description,
description = "Konichiwa, myself Minato Namikaze, Konohagakure Yondaime Hokage, I try my best to do every work as a Hokage!",
chunk_guilds_at_startup=False,
heartbeat_timeout=150.0,
allowed_mentions=allowed_mentions,
Expand All @@ -74,13 +80,11 @@ def get_prefix(self, bot, message):

def run(self):
try:
import sentry_sdk
from sentry_sdk.integrations import AioHttpIntegration


sentry_sdk.init(
sentry_link,
Tokens.sentry_link.value,
traces_sample_rate=1.0,
integrations=[AioHttpIntegration(), ThreadingIntegration(), LoggingIntegration(), ModulesIntegration(), ModulesIntegration()]
integrations=[AioHttpIntegration(), ThreadingIntegration(), LoggingIntegration(), ModulesIntegration()]
)
log.info('Sentry Setup Done')

Expand Down Expand Up @@ -110,7 +114,7 @@ def run(self):
pass

log.info('Bot will now start')
super().run(var.Tokens.token, reconnect=True)
super().run(Tokens.token.value, reconnect=True)
except discord.PrivilegedIntentsRequired:
log.critical(
"[Login Failure] You need to enable the server members intent on the Discord Developers Portal."
Expand Down Expand Up @@ -187,4 +191,4 @@ async def on_ready(self):
)

if __name__ == "__main__":
MinatoNamikazeBot.run()
MinatoNamikazeBot().run()
eitozx marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ idna==3.2
mal-api==0.4.0
multidict==5.1.0
mystbin.py==2.1.3
parsedatetime==2.6
Pillow==8.3.2
psutil==5.8.0
pycparser==2.20
PyNaCl==1.4.0
python-dateutil==2.8.2
python-dotenv==0.19.0
pypresence==4.2.0
pytz==2021.1
requests==2.26.0
sentry-sdk==1.3.1
Expand Down