This commit is contained in:
DasMoorhuhn 2023-03-03 00:53:51 +01:00
parent 24aa41f8d7
commit 7c6f1f84e2

View File

@ -58,17 +58,17 @@ startTime = getDateTime()[2]
bot = client(intents=discord.Intents.all()) bot = client(intents=discord.Intents.all())
tree = app_commands.CommandTree(client=bot) tree = app_commands.CommandTree(client=bot)
async def chnagePresence(): async def chnagePresence(intervalInSeconds=60):
while True: while True:
await bot.change_presence(activity=Game(name="with penguins"), status=Status.online) await bot.change_presence(activity=Game(name="with penguins"), status=Status.online)
await asyncio.sleep(20) await asyncio.sleep(intervalInSeconds)
countGuilds = 0 countGuilds = 0
async for guild in bot.fetch_guilds(): async for guild in bot.fetch_guilds():
countGuilds += 1 countGuilds += 1
await bot.change_presence(activity=Game(name=f"on {countGuilds} Servers"), status=Status.online) await bot.change_presence(activity=Game(name=f"on {countGuilds} Servers"), status=Status.online)
await asyncio.sleep(20) await asyncio.sleep(intervalInSeconds)
@bot.event @bot.event
async def on_ready(): async def on_ready():
@ -87,10 +87,12 @@ async def on_guild_join(guild: Guild):
@tree.command(name='excuse', description='Get a random excuse from programmingexcuses') @tree.command(name='excuse', description='Get a random excuse from programmingexcuses')
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
logger.info("Command: excuse")
await interaction.response.send_message(programmerExcuses.getExcuse()) await interaction.response.send_message(programmerExcuses.getExcuse())
@tree.command(name='get-latest-comic', description='Get latest comic from XKCD') @tree.command(name='get-latest-comic', description='Get latest comic from XKCD')
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
logger.info("Command: get-latest-comic")
comic = xkcd.getLastComic() comic = xkcd.getLastComic()
embed = discord.Embed(title=comic.title, color=Color.blue(), url=f"{xkcd.url}/{comic.num}") embed = discord.Embed(title=comic.title, color=Color.blue(), url=f"{xkcd.url}/{comic.num}")
@ -99,6 +101,7 @@ async def slash(interaction: Interaction):
@tree.command(name='get-random-comic', description='Get a random comic from XKCD') @tree.command(name='get-random-comic', description='Get a random comic from XKCD')
async def slash(interaction: Interaction): async def slash(interaction: Interaction):
logger.info("Command: get-random-comic")
comic = xkcd.getRandomComic() comic = xkcd.getRandomComic()
embed = discord.Embed(title=comic.title, color=Color.blue(), url=f"{xkcd.url}/{comic.num}") embed = discord.Embed(title=comic.title, color=Color.blue(), url=f"{xkcd.url}/{comic.num}")
@ -124,7 +127,7 @@ async def slash(interaction: Interaction):
botString += f"Developer : DasMoorhuhn.py#2604\n" botString += f"Developer : DasMoorhuhn.py#2604\n"
botString += f"Sourcecode: https://gitlab.com/HendrikHeine/tux-discord-bot" botString += f"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 Bot", 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="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)