diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..786f212 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +token= +apikey= diff --git a/.gitignore b/.gitignore index 211007d..27fd60c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /nbproject/ *__pycache__* +.env diff --git a/ftsbot/cogs/channelmoderation.py b/ftsbot/cogs/channelmoderation.py index a2b5156..4a6d555 100644 --- a/ftsbot/cogs/channelmoderation.py +++ b/ftsbot/cogs/channelmoderation.py @@ -7,7 +7,7 @@ import discord from dislash import * from discord.ext import commands -from ftsbot import data, secrets +from ftsbot import config, data class channelmoderation(commands.Cog): def __init__(self, bot): @@ -44,7 +44,7 @@ async def channelcreate(self, ctx, member): overwrites[admin_role1] = discord.PermissionOverwrite(read_messages=True) if admin_role2 is not None: overwrites[admin_role2] = discord.PermissionOverwrite(read_messages=True) - channel = await guild.create_text_channel('temp_' + member.name, overwrites=overwrites, category=self.bot.get_channel(int(secrets.privcat))) + channel = await guild.create_text_channel('temp_' + member.name, overwrites=overwrites, category=self.bot.get_channel(int(config.privcat))) await channel.send('This channel was created to discuss the private request of ' + member.mention) @slash_commands.has_any_role('Admins', 'Liquipedia Staff') @@ -59,7 +59,7 @@ async def channelcopy(self, ctx, channel=None): else: await ctx.send(embed=discord.Embed(colour=discord.Colour(0x00ff00), description='Messages have been archived')) emptyarray = [] - logtarget = self.bot.get_channel(secrets.logtarget) + logtarget = self.bot.get_channel(config.logtarget) async for message in channel.history(limit=10000, oldest_first=True): time = message.created_at embed = discord.Embed( @@ -85,7 +85,7 @@ async def channelkill(self, ctx, channel=None): else: await ctx.send(embed=discord.Embed(colour=discord.Colour(0x00ff00), description='Messages have been archived')) emptyarray = [] - logtarget = self.bot.get_channel(secrets.logtarget) + logtarget = self.bot.get_channel(config.logtarget) async for message in channel.history(limit=10000, oldest_first='true'): time = message.created_at embed = discord.Embed( diff --git a/ftsbot/config.py b/ftsbot/config.py new file mode 100644 index 0000000..966c06e --- /dev/null +++ b/ftsbot/config.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +# License MIT +# Copyright 2016-2021 Alex Winkler +# Version 3.0.0 + +author = 138719439834185728 + +logtarget = 339287109988909057 # Here the channel id of the channel we want the private channel logs to be stored in +privcat = 360564294401916929 # This is the id of the "Private Channels" Category diff --git a/ftsbot/functions/decoratorfunctions.py b/ftsbot/functions/decoratorfunctions.py index 6a7ab0f..1843098 100644 --- a/ftsbot/functions/decoratorfunctions.py +++ b/ftsbot/functions/decoratorfunctions.py @@ -6,11 +6,11 @@ from discord.ext import commands from dislash import * -from ftsbot import secrets +from ftsbot import config def is_bot_owner(): def predicate(ctx): if ctx.guild is None: return False - return ctx.author.id == secrets.author + return ctx.author.id == config.author return check(predicate) diff --git a/ftsbot/secrets.py b/ftsbot/secrets.py index cf13b9e..c3724f9 100644 --- a/ftsbot/secrets.py +++ b/ftsbot/secrets.py @@ -6,7 +6,12 @@ token = '' apikey = '' -author = 138719439834185728 -logtarget = 339287109988909057 # Here the channel id of the channel we want the private channel logs to be stored in -privcat = 360564294401916929 # This is the id of the "Private Channels" Category +with open('.env', 'r') as f: + for line in f.readlines(): + try: + key, value = line.split('=') + locals()[key] = value + except ValueError: + # syntax error + pass diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..341c792 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +discord.py>=1.7.3 +dislash.py>=1.2.4 +requests>=2.26.0