mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-17 17:04:59 +00:00
Add Dockerfile
Update blacklist Clean up e621 code
This commit is contained in:
parent
dbe660ded9
commit
d28a759f8e
24 changed files with 119 additions and 37 deletions
71
Bot/lynxie/main.py
Normal file
71
Bot/lynxie/main.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python3
|
||||
# vim: set fileencoding=utf-8 :
|
||||
|
||||
import asyncio
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.gateway import DiscordWebSocket
|
||||
|
||||
from lynxie.config import DISCORD_TOKEN, LYNXIE_PREFIX
|
||||
from lynxie.database import CommandHistory, Database
|
||||
from lynxie.utils import mobile_status, error_message
|
||||
from lynxie.commands import Help, Ping, Hello, Music, Animals, Img, E621
|
||||
|
||||
|
||||
db = Database()
|
||||
DiscordWebSocket.identify = mobile_status
|
||||
lynxie = commands.Bot(
|
||||
intents=discord.Intents.all(),
|
||||
command_prefix=LYNXIE_PREFIX,
|
||||
help_command=None,
|
||||
)
|
||||
|
||||
|
||||
@lynxie.event
|
||||
async def on_ready():
|
||||
print(f"Logged in as {lynxie.user} (ID: {lynxie.user.id})")
|
||||
|
||||
|
||||
@lynxie.event
|
||||
async def on_command(ctx):
|
||||
if ctx.author == lynxie.user or ctx.author.bot:
|
||||
return
|
||||
|
||||
query = CommandHistory(
|
||||
command=ctx.command.name,
|
||||
user=ctx.author.id,
|
||||
channel=ctx.channel.id,
|
||||
guild=ctx.guild.id,
|
||||
timestamp=ctx.message.created_at,
|
||||
)
|
||||
|
||||
db.session.add(query)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@lynxie.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.CommandNotFound):
|
||||
return
|
||||
|
||||
print(error)
|
||||
|
||||
error = "An internal error occurred while processing your command, oopsie..."
|
||||
await ctx.reply(embed=error_message(error), delete_after=5)
|
||||
|
||||
|
||||
async def run():
|
||||
async with lynxie:
|
||||
await lynxie.add_cog(Help(lynxie))
|
||||
await lynxie.add_cog(Ping(lynxie))
|
||||
await lynxie.add_cog(Hello(lynxie))
|
||||
await lynxie.add_cog(Music(lynxie))
|
||||
await lynxie.add_cog(Animals(lynxie))
|
||||
await lynxie.add_cog(Img(lynxie))
|
||||
await lynxie.add_cog(E621(lynxie))
|
||||
await lynxie.start(DISCORD_TOKEN)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run())
|
Loading…
Add table
Add a link
Reference in a new issue