Skip to content

Commit

Permalink
chore: Version bump to v5.1.7 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ue-Dev authored Jul 7, 2023
2 parents 067d4ad + 5fe4dab commit cab0d08
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 26 deletions.
31 changes: 18 additions & 13 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

import asyncio
import logging
from datetime import datetime, timedelta
import datetime
import interactions
from interactions.ext.prefixed_commands import setup as prefixed_setup
from interactions.ext.hybrid_commands import setup as hybrid_setup
from const import TOKEN, VERSION
from utils.utils import get_response


def get_local_time() -> datetime:
def get_local_time() -> datetime.datetime:
"""Returns latest UTC+7 time."""

utc_time = datetime.utcnow()
local_time = utc_time + timedelta(hours=7)
utc_time = datetime.datetime.now(tz=datetime.timezone.utc)
local_time = utc_time + datetime.timedelta(hours=7)
return local_time


Expand Down Expand Up @@ -69,9 +69,9 @@ async def on_startup() -> None:
counted = True

websocket = f"{client.latency * 1:.0f}"
log_time = (datetime.utcnow() + timedelta(hours=7)).strftime(
"%d/%m/%Y %H:%M:%S"
)
log_time = (
datetime.datetime.utcnow() + datetime.timedelta(hours=7)
).strftime("%d/%m/%Y %H:%M:%S")

print(
"".join(
Expand Down Expand Up @@ -108,18 +108,22 @@ async def on_guild_join(guild: interactions.events.GuildJoin) -> None:

_guild = guild.guild
_channel = client.get_channel(957090401418899526)
current_time: float = round(
datetime.datetime.now(tz=datetime.timezone.utc).timestamp()
)

embed = interactions.Embed(title=f"Joined {_guild.name}")
embed.add_field(name="ID", value=f"{_guild.id}", inline=True)
embed.add_field(
name="Joined on",
value=f"{_guild.joined_at}",
value=f"{round(current_time)}",
inline=True,
)
embed.add_field(
name="Member", value=f"{_guild.member_count}", inline=True
)
embed.set_thumbnail(url=f"{_guild.icon.url}")
if _guild.icon:
embed.set_thumbnail(url=f"{_guild.icon.url}")

await _channel.send(embeds=embed)

Expand All @@ -129,9 +133,9 @@ async def on_guild_left(guild: interactions.events.GuildLeft) -> None:

_guild = guild.guild
_channel = client.get_channel(957090401418899526)
current_time: float = (
datetime.utcnow() + timedelta(hours=7)
).timestamp()
current_time: float = round(
datetime.datetime.now(tz=datetime.timezone.utc).timestamp()
)

embed = interactions.Embed(title=f"Left {_guild.name}")
embed.add_field(name="ID", value=f"{_guild.id}", inline=True)
Expand All @@ -143,7 +147,8 @@ async def on_guild_left(guild: interactions.events.GuildLeft) -> None:
embed.add_field(
name="Member", value=f"{_guild.member_count}", inline=True
)
embed.set_thumbnail(url=f"{_guild.icon.url}")
if _guild.icon:
embed.set_thumbnail(url=f"{_guild.icon.url}")

await _channel.send(embeds=embed)

Expand Down
26 changes: 14 additions & 12 deletions exts/fun/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, client: interactions.Client) -> None:
),
],
)
@interactions.cooldown(interactions.Buckets.USER, 1, 10)
async def img(self, ctx: HybridContext, *, query: str) -> None:
"""Search for images (Powered by Google)."""

Expand Down Expand Up @@ -93,13 +94,14 @@ async def img(self, ctx: HybridContext, *, query: str) -> None:
searchType="image", # sort="date"
).execute()

for i in (0, len(result) - 1):
for i in range(0, 10):
print(i)
all_result.append(
Image(
link=result["items"][i]["link"],
title=result["items"][ran]["title"],
source=result["items"][ran]["displayLink"],
contextlink=result["items"][ran]["image"]["contextLink"],
title=result["items"][i]["title"],
source=result["items"][i]["displayLink"],
contextlink=result["items"][i]["image"]["contextLink"],
)
)

Expand All @@ -112,7 +114,7 @@ async def img(self, ctx: HybridContext, *, query: str) -> None:
color=0x000000,
)
embed.set_footer(
text=f"Google Search • Page {ran}/99",
text=f"Google Search • Page {ran}/9",
icon_url=self.google_icon,
)
embed.add_field(
Expand Down Expand Up @@ -140,7 +142,7 @@ def _check(_ctx):
)

if res.ctx.custom_id == "next":
if ran == 99:
if ran == 9:
ran = ran
else:
ran += 1
Expand All @@ -151,7 +153,7 @@ def _check(_ctx):
color=0x000000,
)
embed.set_footer(
text=f"Google Search • Page {ran}/99",
text=f"Google Search • Page {ran}/9",
icon_url=self.google_icon,
)
embed.add_field(
Expand All @@ -177,7 +179,7 @@ def _check(_ctx):
color=0x000000,
)
embed.set_footer(
text=f"Google Search • Page {ran}/99",
text=f"Google Search • Page {ran}/9",
icon_url=self.google_icon,
)
embed.add_field(
Expand All @@ -192,15 +194,15 @@ def _check(_ctx):
)

elif res.ctx.custom_id == "random":
ran = random.randint(0, 100)
ran = random.randint(0, 9)
all_res = all_result[ran]

embed = interactions.Embed(
title=f"Image for: {query}",
color=0x000000,
)
embed.set_footer(
text=f"Google Search • Page {ran}/99",
text=f"Google Search • Page {ran}/9",
icon_url=self.google_icon,
)
embed.add_field(
Expand Down Expand Up @@ -236,7 +238,7 @@ def check(_message: interactions.Message):
if (
_msg.message.content.isdigit() is False
or int(_msg.message.content) < 0
or int(_msg.message.content) > 99
or int(_msg.message.content) > 10
):
await res.ctx.send(
"That is not a valid number.",
Expand All @@ -251,7 +253,7 @@ def check(_message: interactions.Message):
color=0x000000,
)
embed.set_footer(
text=f"Google Search • Page {ran}/99",
text=f"Google Search • Page {ran}/9",
icon_url=self.google_icon,
)
embed.add_field(
Expand Down
1 change: 1 addition & 0 deletions exts/fun/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ async def get_question(self, category: str, difficulty: str) -> list:
),
],
)
@interactions.cooldown(interactions.Buckets.USER, 1, 10)
async def trivia(
self,
ctx: HybridContext,
Expand Down
1 change: 1 addition & 0 deletions exts/fun/urban.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, client: interactions.Client) -> None:
)
],
)
@interactions.cooldown(interactions.Buckets.USER, 1, 7)
async def urban(self, ctx: HybridContext, *, term: str) -> None:
"""Define a word on Urban Dictionary."""

Expand Down
1 change: 1 addition & 0 deletions exts/fun/whos_that_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, client: interactions.Client) -> None:
),
],
)
@interactions.cooldown(interactions.Buckets.USER, 3, 10)
async def whos_that_pokemon(
self,
ctx: HybridContext,
Expand Down
3 changes: 3 additions & 0 deletions exts/server/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ async def on_guild_member_remove(

member = _member.member
guild = self.client.get_guild(_member.guild_id)
if not guild:
return

embed = interactions.Embed(
title="Goodbye! 😢",
description="".join(
Expand Down
3 changes: 3 additions & 0 deletions exts/utils/snipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ async def on_message_delete(
"""Listen to MESSAGE_DELETE and write to cache."""

message: interactions.Message = msg.message
if not isinstance(message, interactions.Message):
return

_channel_id = str(message.channel.id)

_snipe_message_author[_channel_id] = str(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Articuno"
version = "v5.1.6"
version = "v5.1.7"
description = "A fun Discord Bot, written with interactions.py."
license = "GPL-3.0-only"
authors = ["B1ue-Dev <b1uedev@duck.com>"]
Expand Down

0 comments on commit cab0d08

Please sign in to comment.