Structure
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
run.sh
|
||||||
|
.env/
|
||||||
|
__pycache__/
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
## DemocracyBot
|
||||||
|
Discord bot for managing democratic invitations to join a server.
|
||||||
|
|
||||||
|
### Workflow
|
||||||
|
```mermaid
|
||||||
|
graph TD;
|
||||||
|
A[User] -->|Tells bot to invite a user| B[Bot];
|
||||||
|
B -->|Creates a poll| C[Poll];
|
||||||
|
C --> |If 50% active members vote yes| D[Invite User];
|
||||||
|
C --> |If 50% active members vote no| E[Do not invite user];
|
||||||
|
```
|
||||||
|
|
||||||
|
### Active users
|
||||||
|
We keep track of active users by checking for activity[^1]. No messages are logged, only the fact that a user has been active.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[^1]: Message, reaction, or voice activity in the last 30 days.
|
0
src/cogs/__init__.py
Normal file
0
src/cogs/__init__.py
Normal file
11
src/cogs/activitymonitor.py
Normal file
11
src/cogs/activitymonitor.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
from discord.ext import commands
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class ActivityMonitorCog(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(ActivityMonitorCog(bot))
|
||||||
|
|
11
src/cogs/frengiver.py
Normal file
11
src/cogs/frengiver.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
from discord.ext import commands
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class FrenGiverCog(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(FrenGiverCog(bot))
|
||||||
|
|
11
src/cogs/poll.py
Normal file
11
src/cogs/poll.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
from discord.ext import commands
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class PollCog(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(PollCog(bot))
|
||||||
|
|
41
src/main.py
Normal file
41
src/main.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import asyncio
|
||||||
|
from discord.ext import commands
|
||||||
|
import discord
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format="%(asctime)s [%(levelname)s] %(message)s",
|
||||||
|
datefmt="%Y-%m-%d %H:%M:%S",
|
||||||
|
)
|
||||||
|
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||||
|
|
||||||
|
async def load_cogs():
|
||||||
|
cog_directory = "cogs"
|
||||||
|
for filename in os.listdir(cog_directory):
|
||||||
|
if filename.endswith(".py") and not filename.startswith("__"):
|
||||||
|
cog_name = f"{cog_directory}.{filename[:-3]}"
|
||||||
|
try:
|
||||||
|
await bot.load_extension(cog_name) # Await load_extension
|
||||||
|
logging.info(f"Loaded cog: {cog_name}")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Failed to load cog {cog_name}: {e}")
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
logging.info(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||||
|
logging.info("Bot is ready.")
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with bot:
|
||||||
|
await load_cogs()
|
||||||
|
await bot.start(os.getenv("DISCORD_BOT_TOKEN"))
|
||||||
|
|
||||||
|
# Run the bot
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
|
|
Reference in New Issue
Block a user