This commit is contained in:
DasMoorhuhn 2023-03-02 23:55:49 +01:00
parent a53b4fa041
commit 58d0229899
2 changed files with 23 additions and 31 deletions

View File

@ -1,4 +1,4 @@
FROM python:3.11-alpine FROM python:3.11.2-alpine
WORKDIR /app WORKDIR /app

View File

@ -5,7 +5,7 @@ import datetime
import secretHandler import secretHandler
from addons import ProgrammerExcuses from addons import ProgrammerExcuses
from addons import XKCD from addons import XKCD
from addons import RedditProgrammerHumor #from addons import RedditProgrammerHumor
from models.xkcdComic import Comic from models.xkcdComic import Comic
@ -18,8 +18,8 @@ from discord import Guild
from discord import Color from discord import Color
from discord.activity import Game from discord.activity import Game
botVersion = "1.0.1" botVersion = "1.0.23"
botDate = "03.02.2023" botDate = "02.03.2023"
secret = secretHandler.secret() secret = secretHandler.secret()
token = secret.loadSecret("secret.txt") token = secret.loadSecret("secret.txt")
@ -36,7 +36,7 @@ logger.addHandler(handler)
#Init Addons #Init Addons
programmerExcuses = ProgrammerExcuses() programmerExcuses = ProgrammerExcuses()
redditProgrammerHumor = RedditProgrammerHumor() #redditProgrammerHumor = RedditProgrammerHumor()
xkcd = XKCD() xkcd = XKCD()
class client(discord.Client): class client(discord.Client):
@ -85,7 +85,7 @@ async def on_guild_join(guild: Guild):
@tree.command(name='excuse', description='Get a random excuse from programmer excuses') @tree.command(name='excuse', description='Get a random excuse from programmingexcuses')
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
await interaction.response.send_message(programmerExcuses.getExcuse()) await interaction.response.send_message(programmerExcuses.getExcuse())
@ -105,48 +105,40 @@ async def slash(interaction: Interaction):
embed.set_image(url=comic.img) embed.set_image(url=comic.img)
await interaction.response.send_message(embed=embed) await interaction.response.send_message(embed=embed)
@tree.command(name='programmer-humor', description='Get a random Post from r/ProgrammerHumor') #@tree.command(name='programmer-humor', description='Get a random Post from r/ProgrammerHumor')
async def slash(interaction: Interaction): #async def slash(interaction: Interaction):
post = redditProgrammerHumor.getRandomPost() # post = redditProgrammerHumor.getRandomPost()
await interaction.response.send_message("hi") # await interaction.response.send_message("hi")
@tree.command(name="info", description="get info about this server") @tree.command(name="info", description="get info about this bot")
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
logger.info("Command: info") logger.info("Command: info")
timeNow = getDateTime()[2] timeNow = getDateTime()[2]
uptime = timeNow - startTime uptime = timeNow - startTime
serverString = \ botString = ""
f"""\ botString += f"Uptime : {int(round(uptime, 0))}s\n"
Owner: {interaction.guild.owner} botString += f"Version : {botVersion} from {botDate}\n"
Name: {interaction.guild.name} botString += f"Developer : DasMoorhuhn.py#2604\n"
""" botString += f"Sourcecode: https://gitlab.com/HendrikHeine/tux-discord-bot"
botString = \
f"""\
Uptime: {int(round(uptime/60, 1))}m
Version: {botVersion} from {botDate}
Developer: DasMoorhuhn.py#2604
Sourcecode: https://gitlab.com/HendrikHeine/tux-discord-bot
"""
embed = discord.Embed(title=f"Info", description="about this Server", timestamp=datetime.datetime.utcnow(), color=Color.blue()) embed = discord.Embed(title=f"Info", description="about this Server", timestamp=datetime.datetime.utcnow(), color=Color.blue())
#embed.set_thumbnail(url=interaction.guild.icon) #embed.set_thumbnail(url=interaction.guild.icon)
embed.add_field(name="Server", value=serverString, inline=False)
embed.add_field(name="Bot", value=botString, inline=False) embed.add_field(name="Bot", value=botString, inline=False)
await interaction.response.send_message(embed=embed) await interaction.response.send_message(embed=embed)
@tree.command(name="help", description="List of all Commands") @tree.command(name="help", description="List of all Commands")
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
logger.info("Command: help") logger.info("Command: help")
commandListString = \ commandListString = ""
"""\ commandListString += "`/info` : Get infos about the server and the Bot\n"
`/info`: Get infos about the server and the Bot\n commandListString += "`/help` : Get this view\n"
`/get-random-comic`: Not working yet\n commandListString += "`/get-random-comic`: Get a randowm XCCD comic\n"
`/get-latest-comic`: Get latest comic from XKCD\n commandListString += "`/get-latest-comic`: Get latest comic from XKCD\n"
`/help`: Get this view commandListString += "`/excuse` : Get a random excuse from programmingexcuses"
"""
embed = discord.Embed(title=f"Help", description="List of commands", color=Color.blue()) embed = discord.Embed(title=f"Help", description="List of commands", color=Color.blue())
#embed.set_thumbnail(url=interaction.guild.icon) #embed.set_thumbnail(url=interaction.guild.icon)
embed.add_field(name="Commands", value=commandListString, inline=True) embed.add_field(name="Commands", value=commandListString, inline=True)