-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6502307
commit b29f5d2
Showing
4 changed files
with
227 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import datetime | ||
|
||
import hikari | ||
import lightbulb | ||
import pytz | ||
from lightbulb.ext import tasks | ||
|
||
plugin = lightbulb.Plugin("EditWorldClock") | ||
|
||
|
||
def load(bot: lightbulb.BotApp): | ||
@tasks.task(m=5, auto_start=True) | ||
async def edit_world_clock() -> None: | ||
def create_embed(guild_id, u, tz): | ||
user_ = bot.cache.get_member(guild_id, int(u)) | ||
embed = ( | ||
hikari.Embed( | ||
title=f"WorldTimeClock - {user_.display_name}", | ||
description=f"Timezone: {tz}", | ||
) | ||
.set_author(name=f"{user_.display_name}") | ||
.set_thumbnail(user_.avatar_url) | ||
) | ||
now = datetime.datetime.now() | ||
new_tz = pytz.timezone(tz) | ||
new_now = now.astimezone(new_tz) | ||
embed.add_field("Time", f"{new_now}", inline=False) | ||
return embed | ||
|
||
for guild_id in bot.d.data.get_guilds_list(): | ||
embeds = [] | ||
guild_world_clock = bot.d.data.get_world_clock(guild_id) | ||
channel_world_clock = guild_world_clock["channel_id"] | ||
message_world_clock = guild_world_clock["message_id"] | ||
|
||
for u in bot.d.data.get_members_list(guild_id): | ||
member = bot.d.data.get_member(guild_id, u) | ||
if "tz" in member: | ||
embeds.append(create_embed(guild_id, u, member["tz"])) | ||
await bot.rest.edit_message( | ||
channel_world_clock, message_world_clock, None, embeds=embeds | ||
) | ||
|
||
|
||
def unload(bot: lightbulb.BotApp): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import lightbulb | ||
|
||
plugin = lightbulb.Plugin("Ping") | ||
|
||
|
||
@plugin.command | ||
@lightbulb.add_cooldown(5, 1, lightbulb.GuildBucket) | ||
@lightbulb.command("ping", description="The bot's ping.") | ||
@lightbulb.implements(lightbulb.SlashCommand) | ||
async def pingIt(ctx: lightbulb.SlashContext) -> None: | ||
await ctx.respond(f"Pong! Latency: {ctx.bot.heartbeat_latency * 1000:.2f}ms.") | ||
|
||
|
||
def load(bot: lightbulb.BotApp): | ||
bot.add_plugin(plugin) | ||
|
||
|
||
def unload(bot: lightbulb.BotApp): | ||
bot.remove_plugin(plugin) |
Oops, something went wrong.