From 89850b3abeb83531fae239706f950f6a031d0738 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Fri, 21 Jan 2022 10:15:55 +0530 Subject: [PATCH 1/9] Initialize --- .../plugins/admin/{testingExtension.py => adminCommands.py} | 6 ++++++ 1 file changed, 6 insertions(+) rename hawkeye/core/plugins/admin/{testingExtension.py => adminCommands.py} (78%) diff --git a/hawkeye/core/plugins/admin/testingExtension.py b/hawkeye/core/plugins/admin/adminCommands.py similarity index 78% rename from hawkeye/core/plugins/admin/testingExtension.py rename to hawkeye/core/plugins/admin/adminCommands.py index 50dd66b..df020cf 100644 --- a/hawkeye/core/plugins/admin/testingExtension.py +++ b/hawkeye/core/plugins/admin/adminCommands.py @@ -9,6 +9,12 @@ lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR) ) +## Ping +@lightbulb.command("ping", "Shares bot latency.") +async def ping(ctx: lightbulb.Context) -> None: + await ctx.respond(f"Latency: {ctx.bot.heartbeat_latency * 1_000:,.0f} ms.") + + ## Echoes @admin_test.command @lightbulb.option("text", "Repeats your message.", required = True, modifier=lightbulb.commands.OptionModifier.CONSUME_REST) From 0bbe09cd0cddefd03884d2f358ff317a3e0d3122 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Fri, 21 Jan 2022 12:53:54 +0530 Subject: [PATCH 2/9] Plugin changes Added error and fun plugins, added commands to existing plugins and restructured the heirarchy. --- hawkeye/core/plugins/admin/__init__.py | 0 .../admin/{adminCommands.py => admin.py} | 16 ++++++--- hawkeye/core/plugins/admin/error.py | 34 +++++++++++++++++++ hawkeye/core/plugins/common/fun.py | 28 +++++++++++++++ .../common/{someOtherPlugin.py => info.py} | 10 +++--- 5 files changed, 80 insertions(+), 8 deletions(-) delete mode 100644 hawkeye/core/plugins/admin/__init__.py rename hawkeye/core/plugins/admin/{adminCommands.py => admin.py} (64%) create mode 100644 hawkeye/core/plugins/admin/error.py create mode 100644 hawkeye/core/plugins/common/fun.py rename hawkeye/core/plugins/common/{someOtherPlugin.py => info.py} (91%) diff --git a/hawkeye/core/plugins/admin/__init__.py b/hawkeye/core/plugins/admin/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hawkeye/core/plugins/admin/adminCommands.py b/hawkeye/core/plugins/admin/admin.py similarity index 64% rename from hawkeye/core/plugins/admin/adminCommands.py rename to hawkeye/core/plugins/admin/admin.py index df020cf..370caa4 100644 --- a/hawkeye/core/plugins/admin/adminCommands.py +++ b/hawkeye/core/plugins/admin/admin.py @@ -4,26 +4,34 @@ from hawkeye.core.bot import Hawkeye # from hawkeye.core.utils.Activity import Activity -admin_test= lightbulb.Plugin("admin_test", description="Handles Admin Plugins") -admin_test.add_checks( +adminPlugin= lightbulb.Plugin("admin", description="Handles Admin Plugins") +adminPlugin.add_checks( lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR) ) ## Ping +@adminPlugin.command @lightbulb.command("ping", "Shares bot latency.") async def ping(ctx: lightbulb.Context) -> None: await ctx.respond(f"Latency: {ctx.bot.heartbeat_latency * 1_000:,.0f} ms.") ## Echoes -@admin_test.command +@adminPlugin.command @lightbulb.option("text", "Repeats your message.", required = True, modifier=lightbulb.commands.OptionModifier.CONSUME_REST) @lightbulb.command("echo", "Echoesss.") @lightbulb.implements(lightbulb.PrefixCommand) async def echo(ctx: lightbulb.Context) -> None: await ctx.respond(ctx.options.text) +## Shutdown +@adminPlugin.command +@lightbulb.command("shutdown", "Shuts down the bot.") +async def shutdown(ctx: lightbulb.Context) -> None: + await ctx.bot.close() def load(bot: lightbulb.BotApp) -> None: - bot.add_plugin(admin_test) + bot.add_plugin(adminPlugin) +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(adminPlugin) \ No newline at end of file diff --git a/hawkeye/core/plugins/admin/error.py b/hawkeye/core/plugins/admin/error.py new file mode 100644 index 0000000..6f7f2c8 --- /dev/null +++ b/hawkeye/core/plugins/admin/error.py @@ -0,0 +1,34 @@ +import logging + +import hikari +import lightbulb +from lightbulb import plugins +from hawkeye.core.bot import Hawkeye + +errorPlugin = lightbulb.Plugin("error") + +@errorPlugin.command +@plugins.listener() +async def on_error(self, event: hikari.ExceptionEvent) -> None: + logging.error("An error has occured.") + +async def on_command_error(self, event: lightbulb.CommandErrorEvent) -> None: + if isinstance(event.exception, lightbulb.errors.CommandNotFound): + return None + + if isinstance(event.exception, lightbulb.errors.NotEnoughArguments): + return await event.context.respond( + "There are some missing arguments: " + ", ".join(event.exception.missing_options) + ) + + if isinstance(event.exception, lightbulb.errors.CommandIsOnCooldown): + return await event.context.respond(f"Command is on cooldown. Try again in {event.exception.retry_after:.0f} seconds.") + + await event.context.respond("An error has occured. Reponses not found.") + raise event.exception + +def load(bot: lightbulb.BotApp) -> None: + bot.add_plugin(errorPlugin) + +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(errorPlugin) \ No newline at end of file diff --git a/hawkeye/core/plugins/common/fun.py b/hawkeye/core/plugins/common/fun.py new file mode 100644 index 0000000..b997e63 --- /dev/null +++ b/hawkeye/core/plugins/common/fun.py @@ -0,0 +1,28 @@ +from ast import alias +from random import random +from smtplib import _Reply +import hikari +import lightbulb +import random +from datetime import datetime + +funPlugin = lightbulb.Plugin("fun") + +##Greets member +@funPlugin.command +@lightbulb.command("hello", aliases=("hi", "hey")) +async def hello(ctx: lightbulb.Context) -> None: + greeting = random.choice(("Hello", "Hi", "Hey", "Hey there", "Hello there")) + await ctx.respond(f"{greeting}!", reply=True, mentions_reply=True,) + +##Rolls dice (in progress) +@funPlugin.command +@lightbulb.command("dice", aliases="roll, ") +async def dice(ctx: lightbulb.Context, dice: str) -> None: + number, highest = (int(term) for term in dice.split("d")) + + if number > 25: + return await ctx.respond("I can only roll upto 25 dice at one time.") + + rolls = [random.randint(1, highest) for i in range(number)] + await ctx.respond("+".join(str(r) for r in rolls) + (f" = {sum(rolls):, }"), reply=True, mentions_reply=True,) \ No newline at end of file diff --git a/hawkeye/core/plugins/common/someOtherPlugin.py b/hawkeye/core/plugins/common/info.py similarity index 91% rename from hawkeye/core/plugins/common/someOtherPlugin.py rename to hawkeye/core/plugins/common/info.py index def012b..2bebd54 100644 --- a/hawkeye/core/plugins/common/someOtherPlugin.py +++ b/hawkeye/core/plugins/common/info.py @@ -2,10 +2,10 @@ import lightbulb from datetime import datetime -testPlugin = lightbulb.Plugin("test") +infoPlugin = lightbulb.Plugin("info") ## Returns info about the user -@testPlugin.command +@infoPlugin.command @lightbulb.option("target", "The member to get information about.", hikari.User, required=False) @lightbulb.command("userinfo", "Get info on a server member.") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) @@ -57,6 +57,8 @@ async def userinfo(ctx: lightbulb.Context) -> None: await ctx.respond(embed) - def load(bot: lightbulb.BotApp) -> None: - bot.add_plugin(testPlugin) + bot.add_plugin(infoPlugin) + +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(infoPlugin) \ No newline at end of file From e5c86280a0d7728d5658a8ad11dbc5c68ef250c3 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Sun, 23 Jan 2022 12:06:32 +0530 Subject: [PATCH 3/9] Addded External plugin and modified bot.py for better response times. --- hawkeye/core/bot.py | 8 +++ hawkeye/core/plugins/admin/__init__.py | 0 hawkeye/core/plugins/admin/admin.py | 7 +++ hawkeye/core/plugins/common/external.py | 82 +++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 hawkeye/core/plugins/admin/__init__.py create mode 100644 hawkeye/core/plugins/common/external.py diff --git a/hawkeye/core/bot.py b/hawkeye/core/bot.py index 5eca55b..067c6dd 100644 --- a/hawkeye/core/bot.py +++ b/hawkeye/core/bot.py @@ -1,9 +1,13 @@ import asyncio +from asyncio.subprocess import STDOUT import hikari import lightbulb from hawkeye.core.utils.Activity import Activity from hawkeye import bot_config +HOME_GUILD_ID: 870647011899220040 +STDOUT_CHANNEL_ID: 931779674118451230 + class Hawkeye(lightbulb.BotApp): def __init__(self) -> None: @@ -41,6 +45,10 @@ async def on_started(self, _: hikari.StartedEvent) -> None: asyncio.create_task(Activity(self).change_status()) print("Bot has started sucessfully.") + self.home_guild = self.cache.get_guild(HOME_GUILD_ID) + self.stdout_channel = self.home_guild.get_channel(STDOUT_CHANNEL_ID) + await self.stdout_channel.send(f"Testing... now online!") + async def on_stopping(self, _: hikari.StoppingEvent) -> None: print("Bot is stopping...") diff --git a/hawkeye/core/plugins/admin/__init__.py b/hawkeye/core/plugins/admin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hawkeye/core/plugins/admin/admin.py b/hawkeye/core/plugins/admin/admin.py index 370caa4..434f129 100644 --- a/hawkeye/core/plugins/admin/admin.py +++ b/hawkeye/core/plugins/admin/admin.py @@ -1,3 +1,4 @@ +from bisect import insort_right import hikari import lightbulb @@ -9,6 +10,12 @@ lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR) ) +##Bot reload +@adminPlugin.command +@lightbulb.command("reload", "Reloads the bot") +async def reload(ctx: lightbulb.Context, plugin: str) -> None: + pass + ## Ping @adminPlugin.command @lightbulb.command("ping", "Shares bot latency.") diff --git a/hawkeye/core/plugins/common/external.py b/hawkeye/core/plugins/common/external.py new file mode 100644 index 0000000..c7556c0 --- /dev/null +++ b/hawkeye/core/plugins/common/external.py @@ -0,0 +1,82 @@ +import lightbulb + +externalPlugin = lightbulb.Plugin("External") + +##Hawkye Github repo +@externalPlugin.command +@lightbulb.command("src", "Returns main Hawkeye repo.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def src(ctx: lightbulb.Context) -> None: + await ctx.respond(f"") +async def src(ctx: lightbulb.SlashContext) -> None: + await ctx.respond(f"") + +##Enigma Github +@externalPlugin.command +@lightbulb.command("git", "Returns the Enigma Github") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def src(ctx: lightbulb.Context) -> None: + await ctx.respond(f"") +async def src(ctx: lightbulb.SlashContext) -> None: + await ctx.respond(f"") + +##Enigma website +@externalPlugin.command +@lightbulb.command("website", "Returns the Enigma website") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def src(ctx: lightbulb.Context) -> None: + await ctx.respond(f"") +async def src(ctx: lightbulb.SlashContext) -> None: + await ctx.respond(f"") + +##Google search +@externalPlugin.command +@lightbulb.option("query", "The thing to search.") +@lightbulb.command("google", "Let me Google that for you...") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def google(ctx: lightbulb.Context) -> None: + q = ctx.options.query + + if len(q) > 500: + await ctx.respond("Your query should be no longer than 500 characters.") + return + + await ctx.respond(f"") + +async def google(ctx: lightbulb.SlashContext) -> None: + q = ctx.options.query + + if len(q) > 500: + await ctx.respond("Your query should be no longer than 500 characters.") + return + + await ctx.respond(f"") + +##DuckDuckGo search +@externalPlugin.command +@lightbulb.option("query", "The thing to search.") +@lightbulb.command("duckduckgo", "Let me Duck Duck Go that for you...") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def duckduckgo(ctx: lightbulb.Context) -> None: + q = ctx.options.query + + if len(q) > 500: + await ctx.respond("Your query should be no longer than 500 characters.") + return + + await ctx.respond(f"") + +async def duckduckgo(ctx: lightbulb.SlashContext) -> None: + q = ctx.options.query + + if len(q) > 500: + await ctx.respond("Your query should be no longer than 500 characters.") + return + + await ctx.respond(f"") + +def load(bot: lightbulb.BotApp) -> None: + bot.add_plugin(externalPlugin) + +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(externalPlugin) \ No newline at end of file From ef43a3dde933d176198aa73936ff211d9a9dee05 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Sun, 23 Jan 2022 19:33:23 +0530 Subject: [PATCH 4/9] Added more Fun commands, added moderation plugin --- hawkeye/core/bot.py | 4 +- hawkeye/core/plugins/admin/admin.py | 22 +- hawkeye/core/plugins/admin/error.py | 3 + hawkeye/core/plugins/admin/moderation.py | 58 +++++ hawkeye/core/plugins/common/external.py | 52 +++++ hawkeye/core/plugins/common/fun.py | 265 +++++++++++++++++++++-- hawkeye/core/plugins/common/info.py | 25 +++ requirements.txt | 1 + 8 files changed, 398 insertions(+), 32 deletions(-) create mode 100644 hawkeye/core/plugins/admin/moderation.py diff --git a/hawkeye/core/bot.py b/hawkeye/core/bot.py index 067c6dd..5fdba1b 100644 --- a/hawkeye/core/bot.py +++ b/hawkeye/core/bot.py @@ -5,7 +5,6 @@ from hawkeye.core.utils.Activity import Activity from hawkeye import bot_config -HOME_GUILD_ID: 870647011899220040 STDOUT_CHANNEL_ID: 931779674118451230 class Hawkeye(lightbulb.BotApp): @@ -45,8 +44,7 @@ async def on_started(self, _: hikari.StartedEvent) -> None: asyncio.create_task(Activity(self).change_status()) print("Bot has started sucessfully.") - self.home_guild = self.cache.get_guild(HOME_GUILD_ID) - self.stdout_channel = self.home_guild.get_channel(STDOUT_CHANNEL_ID) + self.stdout_channel = await self.rest.fetch_channel(STDOUT_CHANNEL_ID) await self.stdout_channel.send(f"Testing... now online!") diff --git a/hawkeye/core/plugins/admin/admin.py b/hawkeye/core/plugins/admin/admin.py index 434f129..4f53c37 100644 --- a/hawkeye/core/plugins/admin/admin.py +++ b/hawkeye/core/plugins/admin/admin.py @@ -1,4 +1,5 @@ from bisect import insort_right +import logging import hikari import lightbulb @@ -10,11 +11,13 @@ lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR) ) -##Bot reload +## Extension reload @adminPlugin.command -@lightbulb.command("reload", "Reloads the bot") -async def reload(ctx: lightbulb.Context, plugin: str) -> None: - pass +@lightbulb.command("reload", "Reloads the bot extension") +async def reload(self, ctx: lightbulb.Context, extensions: str) -> None: + for ext in extensions.split(" "): + ctx.bot.reload_extensions(ext) + logging.info(f"{ext} extension reloaded") ## Ping @adminPlugin.command @@ -22,20 +25,11 @@ async def reload(ctx: lightbulb.Context, plugin: str) -> None: async def ping(ctx: lightbulb.Context) -> None: await ctx.respond(f"Latency: {ctx.bot.heartbeat_latency * 1_000:,.0f} ms.") - -## Echoes -@adminPlugin.command -@lightbulb.option("text", "Repeats your message.", required = True, modifier=lightbulb.commands.OptionModifier.CONSUME_REST) -@lightbulb.command("echo", "Echoesss.") -@lightbulb.implements(lightbulb.PrefixCommand) -async def echo(ctx: lightbulb.Context) -> None: - await ctx.respond(ctx.options.text) - ## Shutdown @adminPlugin.command @lightbulb.command("shutdown", "Shuts down the bot.") async def shutdown(ctx: lightbulb.Context) -> None: - await ctx.bot.close() + await ctx.bot.close(force=False) def load(bot: lightbulb.BotApp) -> None: bot.add_plugin(adminPlugin) diff --git a/hawkeye/core/plugins/admin/error.py b/hawkeye/core/plugins/admin/error.py index 6f7f2c8..c44d5a5 100644 --- a/hawkeye/core/plugins/admin/error.py +++ b/hawkeye/core/plugins/admin/error.py @@ -24,6 +24,9 @@ async def on_command_error(self, event: lightbulb.CommandErrorEvent) -> None: if isinstance(event.exception, lightbulb.errors.CommandIsOnCooldown): return await event.context.respond(f"Command is on cooldown. Try again in {event.exception.retry_after:.0f} seconds.") + if isinstance(event.exception, lightbulb.errors.CommandInvocationError): + raise event.exception.original + await event.context.respond("An error has occured. Reponses not found.") raise event.exception diff --git a/hawkeye/core/plugins/admin/moderation.py b/hawkeye/core/plugins/admin/moderation.py new file mode 100644 index 0000000..d8c8a9e --- /dev/null +++ b/hawkeye/core/plugins/admin/moderation.py @@ -0,0 +1,58 @@ +from typing import Tuple +import hikari +import lightbulb +import random +import re +import datetime + +from time import time +from datetime import timedelta +from lightbulb import commands, context + +modPlugin = lightbulb.Plugin("Mod") + +## Mute +@modPlugin.command +@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.MODERATE_MEMBERS)) +@lightbulb.option("reason", "Reason for mute. Will show up in Audit log.", type = str, modifier = lightbulb.OptionModifier.CONSUME_REST, required = True) +@lightbulb.option("duration", "Time muted for.", str, required = True) +@lightbulb.option("user", "User to mute.", hikari.User, required = True) +@lightbulb.command("mute", "Mutes a user.", auto_defer = True) +@lightbulb.implements(commands.PrefixCommand, commands.SlashCommand) +async def mute(ctx : context.Context) -> None: + target = ctx.options.user + reason = ctx.options.reason + duration = ctx.options.duration + target = ctx.get_guild().get_member(target) + + time_pattern = r"(\d+\.?\d?[s|m|h|d|w]{1})\s?" + + units = { + 's': 'seconds', + 'm': 'minutes', + 'h': 'hours', + 'd': 'days', + 'w': 'weeks' + } + + def parse(time_string: str) -> Tuple[str, float]: + unit = time_string[-1] + amount = float(time_string[:-1]) + return units[unit], amount + + if matched := re.findall(time_pattern, duration, flags=re.I): + time_dict = dict(parse(match) for match in matched) + time_s = int(timedelta(**time_dict).total_seconds()) + else: + raise ("Invalid string format. Time must be in the form [s|m|h|d|w].") + + if not 1 <= time_s <= 2_419_200: + await ctx.respond("The timeout must be between 1 second and 28 days inclusive.") + return + + await target.edit( + communication_disabled_until = (datetime.datetime.utcnow() + datetime.timedelta(seconds=time_s)).isoformat(), + reason = reason + ) + + await ctx.respond(f"Muted {target.mention} until ") diff --git a/hawkeye/core/plugins/common/external.py b/hawkeye/core/plugins/common/external.py index c7556c0..5f9e882 100644 --- a/hawkeye/core/plugins/common/external.py +++ b/hawkeye/core/plugins/common/external.py @@ -1,4 +1,14 @@ +import hikari +from hikari import Color import lightbulb +import wikipedia + +import datetime as dt +from datetime import datetime, time, timedelta +from wikipedia import exceptions + +from wikipedia.wikipedia import languages + externalPlugin = lightbulb.Plugin("External") @@ -75,6 +85,48 @@ async def duckduckgo(ctx: lightbulb.SlashContext) -> None: await ctx.respond(f"") +## Wikipedia search +@externalPlugin.command() +@lightbulb.set_help("Search wikipedia and receive in an embed") +@lightbulb.option("search", "Key word of the search you want") +@lightbulb.command(name="wikipedia", aliases=("wiki","wk"), description="Search a target in wikipedia.") +@lightbulb.implements(lightbulb.SlashCommand) +async def command_wikipedia(ctx: lightbulb.SlashContext) -> None: + try: + message = await ctx.respond("Searching...") + page = wikipedia.page(ctx.options.search) + image = page.images[0] + title = page.title + content = page.content + + if len(content) > 600: + content = content[:600] + "...(READ MORE click on the title)" + + else: + content = content + + title_link = title.replace(" ", "_") + embed = (hikari.Embed( + colour=Color(0x3B9DFF), + description=content, + timestamp=dt.datetime.now().astimezone() + + ) + .set_image(image) + .set_author(name=title,url=f"https://en.wikipedia.org/wiki/{title_link}") + ) + await ctx.respond(embed, reply=True) + await message.delete() + + except(wikipedia.exceptions.DisambiguationError): + await message.edit(content="Try to be clearer with the search, multiple results found.") + + except(wikipedia.exceptions.PageError): + await message.edit(content="Page not found.") + + except(wikipedia.exceptions.HTTPTimeoutError): + await message.edit(content="The servers seem to be down. Please try again later.") + def load(bot: lightbulb.BotApp) -> None: bot.add_plugin(externalPlugin) diff --git a/hawkeye/core/plugins/common/fun.py b/hawkeye/core/plugins/common/fun.py index b997e63..35fac88 100644 --- a/hawkeye/core/plugins/common/fun.py +++ b/hawkeye/core/plugins/common/fun.py @@ -1,28 +1,263 @@ -from ast import alias from random import random -from smtplib import _Reply +import requests +import json import hikari import lightbulb +import requests +from lightbulb import commands +from hikari.colors import Color import random -from datetime import datetime funPlugin = lightbulb.Plugin("fun") -##Greets member +## 8ball @funPlugin.command -@lightbulb.command("hello", aliases=("hi", "hey")) -async def hello(ctx: lightbulb.Context) -> None: - greeting = random.choice(("Hello", "Hi", "Hey", "Hey there", "Hello there")) - await ctx.respond(f"{greeting}!", reply=True, mentions_reply=True,) +@lightbulb.set_help("Give answers to your questions.") +@lightbulb.option("question", "The question you want answers to.") +@lightbulb.command("8ball", description="Make the game of the 8ball.") +@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand) +async def cmd_ball(ctx: lightbulb.SlashContext): + + responses = [ + "It is certain.", + "It is decidedly so.", + "Without a doubt.", + "Yes definitely.", + "You may rely on it.", + "As I see it, yes.", + "Most likely.", + "Outlook good.", + "Yes.", + "Signs point to yes.", + "Reply hazy, try again.", + "Ask again later.", + "Better not tell you now.", + "Cannot predict now.", + "Concentrate and ask again.", + "Don't count on it.", + "My reply is no.", + "My sources say no.", + "Outlook not so good.", + "Very doubtful."] -##Rolls dice (in progress) + + await ctx.respond(f"{random.choice(responses)}") + +## Give cookie +@funPlugin.command +@lightbulb.set_help("Give a cookie (1 hour cooldown).") +@lightbulb.add_cooldown(length=3600, uses=1, bucket=lightbulb.UserBucket) +@lightbulb.option("user", "User you want give the cookie", hikari.Member) +@lightbulb.command(name="givecookie", aliases=("gcookie",), description="Give a cookie to a user.") +@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand) +async def cmd_cookie(ctx: lightbulb.SlashContext) -> None: + + target = ctx.options.user + + if target.id == ctx.member.id: + await ctx.respond("You can't give a cookie to yourself.") + return + + if target.is_bot: + await ctx.respond("You can't give cookies to bots.") + return + + await funPlugin.bot.d.db.execute( + "UPDATE user SET cookies = cookies + 1 WHERE user_id = ?", + target.id + ) + + row = await ctx.bot.d.db.try_fetch_record( + "SELECT cookies FROM user WHERE user_id = ?", + target.id, + ) + + r_g = random.randint(1, 255) + r_b = random.randint(1, 255) + r_r = random.randint(1, 255) + + images_cookies = ["https://i.pinimg.com/originals/fc/39/65/fc3965c433c19f4492d616f975316c8c.gif", "https://64.media.tumblr.com/2f272878761f85dbe7665c1fada53e45/c0f2b8287c49f60d-4b/s540x810/aecab8278a4762d638af1a6dcda55e16c069c458.gif", "https://c.tenor.com/zEWVjcnOt1IAAAAC/anime-eating.gif", "https://c.tenor.com/bBRCCeAYPU8AAAAC/cookie-mashiro.gif"] + + embed = (hikari.Embed( + description=f"You gave a cookie to **{target.username}**, now he/she has **{row.cookies}**", + colour=Color.from_rgb(r_g, r_b, r_r) + + ) + .set_image(random.choice(images_cookies)) + ) + + await ctx.respond(embed) + +## Anime gifs +def get_gif(term, limit = 14) -> str: + with open("./secrets/api-tenor", "r") as f: + api_key = f.readline() + limit = limit + + r = requests.get("https://g.tenor.com/v1/search?q=%s&key=%s&limit=%s" % (term, api_key, limit)) + + + gifs_data = json.loads(r.content) + gif = gifs_data["results"][random.randint(0,limit-1)]["media"][0]["gif"]["url"] + + return + +async def action(ctx: lightbulb.Context, text, image) -> None: + r_g = random.randint(1, 255) + r_b = random.randint(1, 255) + r_r = random.randint(1, 255) + + embed = (hikari.Embed( + description=f"{text}", + colour=Color.from_rgb(r_g, r_b, r_r) + ) + .set_image(image) + ) + + await ctx.respond(embed) + + +## Hugs person mentioned +@funPlugin.command +@lightbulb.set_help("Give a hug to whoever mentions.") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) +@lightbulb.command("hug", "Just hug someone.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_hug(ctx: lightbulb.context) -> None: + target = ctx.options.member + gif = get_gif("anime-hug") + + await action(ctx, f"**{ctx.member.username}** hug to **{target.username}**", gif) + +## Claps for person mentioned @funPlugin.command -@lightbulb.command("dice", aliases="roll, ") -async def dice(ctx: lightbulb.Context, dice: str) -> None: - number, highest = (int(term) for term in dice.split("d")) +@lightbulb.set_help("Clap or clap for someone.") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) +@lightbulb.command("clap", "Just clap or clap for someone.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_clap(ctx: lightbulb.context) -> None: + + target = ctx.options.member + + gif = get_gif("anime-clap") + + if target == None: + await action(ctx, f"**{ctx.member.username}** is clapping", gif) + + else: + await action(ctx, f"**{ctx.member.username}** applauds **{target.username}**", gif) + +## High fives person mentioned +@funPlugin.command +@lightbulb.set_help("Highfive to the person who mentions.") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) +@lightbulb.command("highfive", "Highfive to someone :)") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_highfive(ctx: lightbulb.context) -> None: + + target = ctx.options.member + + gif = get_gif("anime-highfive") + await action(ctx, f"**{ctx.member.username}** highfive to **{target.username}**", gif) + +## Laugh at someone mentioned +@funPlugin.command +@lightbulb.set_help("Laugh or tease someone you mention") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) +@lightbulb.command("laugh", "Laugh or tease.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_laugh(ctx: lightbulb.context) -> None: + + target = ctx.options.member + + gif = get_gif("anime-laugh") + if target == None: + await action(ctx, f"**{ctx.member.username}** is laughing.", gif) + + else: + await action(ctx, f"**{ctx.member.username}** laughs at **{target.username}**", gif) + +## Kiss the person mentioned +@funPlugin.command +@lightbulb.set_help("Kiss the person who mentions.") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) +@lightbulb.command("kiss", "Kiss someone.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_kiss(ctx: lightbulb.context) -> None: + target = ctx.options.member + if target.id == ctx.member.id: + await ctx.respond(f"I don't think you can kiss yourself {ctx.member.mention}") + return + + gif = get_gif("anime-kiss") + await action(ctx, f"**{ctx.member.username}** le dio un beso a **{target.username}**. (づ ̄ ³ ̄)づ", gif) + +## Code grind +@funPlugin.command +@lightbulb.set_help("Show you are changing the world whit code.") +@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) +@lightbulb.command("program", "Programming alone or with someone.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def command_program(ctx: lightbulb.context) -> None: + target = ctx.options.member + gif = get_gif("anime-programmer", limit=3) + + if target == None: + await action(ctx, f"**{ctx.member.username}** is programming something amazing.", gif) + + else: + await action(ctx, f"**{ctx.member.username}** is programming something amazing with **{target.username}**", gif) + +## Converts celsius to farenheit and vice versa +@funPlugin.command +@lightbulb.option('fahrenheit', 'Temperature in Fahrenheit to convert.', required=True, type=float) +@lightbulb.command('celsius', 'Convert Fahrenheit to Celsius.') +@lightbulb.implements(lightbulb.commands.SlashCommand) +async def celsius_command(ctx: lightbulb.context.Context) -> None: + await ctx.respond( + embed=hikari.Embed( + title='Fahrenheit to Celsius', + description=f'({ctx.options.fahrenheit} - 32) * (5/9) = **{((int(ctx.options.fahrenheit) - 32) * (5/9)):.1f}**', + color=hikari.Color(0x289C9C) + ) + ) + +@funPlugin.command +@lightbulb.option('celsius', 'Temperature in Celsius to convert.', required=True, type=float) +@lightbulb.command('fahrenheit', 'Convert Celsius to Fahrenheit.') +@lightbulb.implements(lightbulb.commands.SlashCommand) +async def fahrenheit_command(ctx: lightbulb.context.Context) -> None: + await ctx.respond( + embed=hikari.Embed( + title='Celsius to Fahrenheit', + description=f'{ctx.options.celsius} * (9/5) + 32 = **{(int(ctx.options.celsius) * (9/5) + 32):.1f}**', + color=hikari.Color(0x289C9C) + ) + ) + +## Rolls dice +@funPlugin.command +@lightbulb.option("bonus", "A fixed number to add to the total roll.", int, default=0) +@lightbulb.option("sides", "The number of sides each die will have.", int, default=6) +@lightbulb.option("number", "The number of dice to roll.", int) +@lightbulb.command("dice", "Roll one or more dice.") +@lightbulb.implements(commands.SlashCommand) +async def dice(ctx: lightbulb.context.Context) -> None: + number = ctx.options.number + sides = ctx.options.sides + bonus = ctx.options.bonus if number > 25: - return await ctx.respond("I can only roll upto 25 dice at one time.") + await ctx.respond("No more than 25 dice can be rolled at once.") + return + + if sides > 100: + await ctx.respond("The dice cannot have more than 100 sides.") + return - rolls = [random.randint(1, highest) for i in range(number)] - await ctx.respond("+".join(str(r) for r in rolls) + (f" = {sum(rolls):, }"), reply=True, mentions_reply=True,) \ No newline at end of file + rolls = [random.randint(1, sides) for _ in range(number)] + await ctx.respond( + " + ".join(f"{r}" for r in rolls) + + (f" + {bonus} (bonus)" if bonus else "") + + f" = **{sum(rolls) + bonus:,}**" + ) \ No newline at end of file diff --git a/hawkeye/core/plugins/common/info.py b/hawkeye/core/plugins/common/info.py index 2bebd54..4f954c6 100644 --- a/hawkeye/core/plugins/common/info.py +++ b/hawkeye/core/plugins/common/info.py @@ -1,9 +1,34 @@ import hikari import lightbulb +from lightbulb import commands, context from datetime import datetime +from random import randint infoPlugin = lightbulb.Plugin("info") +## Returns avatar of user +@infoPlugin.command +@lightbulb.option("target", description = "User to fetch avatar of", type = hikari.User, required = False) +@lightbulb.command("avatar", description = "Fetch Avatar of yourself or the specified user.", aliases = ['av', 'pfp'], auto_defer = True) +@lightbulb.implements(commands.PrefixCommand, commands.SlashCommand) +async def avatar_cmd(ctx: context.Context) -> None: + target = ctx.options.target if ctx.options.target is not None else ctx.author + + embed = hikari.Embed( + title = f"Avatar of {target.username}", + color = randint(0, 0x3B9DFF) + ).set_image( + target.avatar_url + ).set_footer( + text = f"Requested by {ctx.author.username}", + icon = ctx.author.avatar_url + ).set_author( + name = f"{ctx.app.get_me().username}", + icon = ctx.app.get_me().avatar_url + ) + + await ctx.respond(embed = embed, reply = True) + ## Returns info about the user @infoPlugin.command @lightbulb.option("target", "The member to get information about.", hikari.User, required=False) diff --git a/requirements.txt b/requirements.txt index 15a9186..1bf1669 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ hikari python-dotenv uvloop>=0.16; sys_platform != "win32" hikari-lightbulb>=2.1.1 +wikipedia>=1.4.0 pydantic \ No newline at end of file From cc37712bb3e80886be8f0de07d7b8b2447d64ed1 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Sun, 23 Jan 2022 19:35:42 +0530 Subject: [PATCH 5/9] Fixed moderation plugin loading --- hawkeye/core/plugins/admin/moderation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hawkeye/core/plugins/admin/moderation.py b/hawkeye/core/plugins/admin/moderation.py index d8c8a9e..0d36d32 100644 --- a/hawkeye/core/plugins/admin/moderation.py +++ b/hawkeye/core/plugins/admin/moderation.py @@ -56,3 +56,9 @@ def parse(time_string: str) -> Tuple[str, float]: ) await ctx.respond(f"Muted {target.mention} until ") + +def load(bot: lightbulb.BotApp) -> None: + bot.add_plugin(modPlugin) + +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(modPlugin) \ No newline at end of file From 7aaf89edad13b5258c1da4f9083b2ac5dcc8f148 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Sun, 23 Jan 2022 22:15:59 +0530 Subject: [PATCH 6/9] Fixed fun.py and removed redundancies from bot.py --- hawkeye/core/bot.py | 6 ------ hawkeye/core/plugins/common/fun.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/hawkeye/core/bot.py b/hawkeye/core/bot.py index 5fdba1b..5632e02 100644 --- a/hawkeye/core/bot.py +++ b/hawkeye/core/bot.py @@ -5,8 +5,6 @@ from hawkeye.core.utils.Activity import Activity from hawkeye import bot_config -STDOUT_CHANNEL_ID: 931779674118451230 - class Hawkeye(lightbulb.BotApp): def __init__(self) -> None: @@ -44,10 +42,6 @@ async def on_started(self, _: hikari.StartedEvent) -> None: asyncio.create_task(Activity(self).change_status()) print("Bot has started sucessfully.") - self.stdout_channel = await self.rest.fetch_channel(STDOUT_CHANNEL_ID) - await self.stdout_channel.send(f"Testing... now online!") - - async def on_stopping(self, _: hikari.StoppingEvent) -> None: print("Bot is stopping...") diff --git a/hawkeye/core/plugins/common/fun.py b/hawkeye/core/plugins/common/fun.py index 35fac88..d4235fb 100644 --- a/hawkeye/core/plugins/common/fun.py +++ b/hawkeye/core/plugins/common/fun.py @@ -196,7 +196,7 @@ async def command_kiss(ctx: lightbulb.context) -> None: @funPlugin.command @lightbulb.set_help("Show you are changing the world whit code.") @lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) -@lightbulb.command("program", "Programming alone or with someone.") +@lightbulb.command("grind", "Programming alone or with someone.") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_program(ctx: lightbulb.context) -> None: target = ctx.options.member From f45b998741430fe42c6ed92c4fc7a2b28c6bcb1f Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Mon, 24 Jan 2022 08:59:12 +0530 Subject: [PATCH 7/9] Added Reddit search to External plugin --- hawkeye/core/plugins/common/external.py | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/hawkeye/core/plugins/common/external.py b/hawkeye/core/plugins/common/external.py index 5f9e882..511af29 100644 --- a/hawkeye/core/plugins/common/external.py +++ b/hawkeye/core/plugins/common/external.py @@ -21,7 +21,7 @@ async def src(ctx: lightbulb.Context) -> None: async def src(ctx: lightbulb.SlashContext) -> None: await ctx.respond(f"") -##Enigma Github +## Sends link to Enigma Github @externalPlugin.command @lightbulb.command("git", "Returns the Enigma Github") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) @@ -30,7 +30,7 @@ async def src(ctx: lightbulb.Context) -> None: async def src(ctx: lightbulb.SlashContext) -> None: await ctx.respond(f"") -##Enigma website +## Sends link to Enigma website @externalPlugin.command @lightbulb.command("website", "Returns the Enigma website") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) @@ -39,7 +39,7 @@ async def src(ctx: lightbulb.Context) -> None: async def src(ctx: lightbulb.SlashContext) -> None: await ctx.respond(f"") -##Google search +## Google search @externalPlugin.command @lightbulb.option("query", "The thing to search.") @lightbulb.command("google", "Let me Google that for you...") @@ -62,7 +62,7 @@ async def google(ctx: lightbulb.SlashContext) -> None: await ctx.respond(f"") -##DuckDuckGo search +## DuckDuckGo search @externalPlugin.command @lightbulb.option("query", "The thing to search.") @lightbulb.command("duckduckgo", "Let me Duck Duck Go that for you...") @@ -127,6 +127,29 @@ async def command_wikipedia(ctx: lightbulb.SlashContext) -> None: except(wikipedia.exceptions.HTTPTimeoutError): await message.edit(content="The servers seem to be down. Please try again later.") +## Reddit search +@externalPlugin.command +@lightbulb.option("query", "The thing to search.") +@lightbulb.command("reddit", "Searching on Reddit.") +@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) +async def reddit(ctx: lightbulb.Context) -> None: + q = ctx.options.query + + if len(q) > 50: + await ctx.respond("Your query should be no longer than 50 characters.") + return + + await ctx.respond(f"") + +async def duckduckgo(ctx: lightbulb.SlashContext) -> None: + q = ctx.options.query + + if len(q) > 50: + await ctx.respond("Your query should be no longer than 50 characters.") + return + + await ctx.respond(f"") + def load(bot: lightbulb.BotApp) -> None: bot.add_plugin(externalPlugin) From 1f9ebcfaf0dfddf4a823b4bb9db9209a318557f0 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Mon, 24 Jan 2022 09:37:02 +0530 Subject: [PATCH 8/9] Fixed typos and removed redundancies. --- hawkeye/core/plugins/admin/admin.py | 8 ---- hawkeye/core/plugins/admin/moderation.py | 3 +- hawkeye/core/plugins/common/external.py | 4 +- hawkeye/core/plugins/common/fun.py | 50 +++++++++++++----------- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/hawkeye/core/plugins/admin/admin.py b/hawkeye/core/plugins/admin/admin.py index 4f53c37..0126640 100644 --- a/hawkeye/core/plugins/admin/admin.py +++ b/hawkeye/core/plugins/admin/admin.py @@ -11,14 +11,6 @@ lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR) ) -## Extension reload -@adminPlugin.command -@lightbulb.command("reload", "Reloads the bot extension") -async def reload(self, ctx: lightbulb.Context, extensions: str) -> None: - for ext in extensions.split(" "): - ctx.bot.reload_extensions(ext) - logging.info(f"{ext} extension reloaded") - ## Ping @adminPlugin.command @lightbulb.command("ping", "Shares bot latency.") diff --git a/hawkeye/core/plugins/admin/moderation.py b/hawkeye/core/plugins/admin/moderation.py index 0d36d32..5f2ff7b 100644 --- a/hawkeye/core/plugins/admin/moderation.py +++ b/hawkeye/core/plugins/admin/moderation.py @@ -1,7 +1,6 @@ from typing import Tuple import hikari import lightbulb -import random import re import datetime @@ -47,7 +46,7 @@ def parse(time_string: str) -> Tuple[str, float]: raise ("Invalid string format. Time must be in the form [s|m|h|d|w].") if not 1 <= time_s <= 2_419_200: - await ctx.respond("The timeout must be between 1 second and 28 days inclusive.") + await ctx.respond("Mute duration must be between 1 second and 28 days.") return await target.edit( diff --git a/hawkeye/core/plugins/common/external.py b/hawkeye/core/plugins/common/external.py index 511af29..917a77e 100644 --- a/hawkeye/core/plugins/common/external.py +++ b/hawkeye/core/plugins/common/external.py @@ -87,8 +87,8 @@ async def duckduckgo(ctx: lightbulb.SlashContext) -> None: ## Wikipedia search @externalPlugin.command() -@lightbulb.set_help("Search wikipedia and receive in an embed") -@lightbulb.option("search", "Key word of the search you want") +@lightbulb.set_help("Search wikipedia.") +@lightbulb.option("query", "The thing to search.") @lightbulb.command(name="wikipedia", aliases=("wiki","wk"), description="Search a target in wikipedia.") @lightbulb.implements(lightbulb.SlashCommand) async def command_wikipedia(ctx: lightbulb.SlashContext) -> None: diff --git a/hawkeye/core/plugins/common/fun.py b/hawkeye/core/plugins/common/fun.py index d4235fb..9554609 100644 --- a/hawkeye/core/plugins/common/fun.py +++ b/hawkeye/core/plugins/common/fun.py @@ -119,21 +119,21 @@ async def action(ctx: lightbulb.Context, text, image) -> None: ## Hugs person mentioned @funPlugin.command -@lightbulb.set_help("Give a hug to whoever mentions.") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) -@lightbulb.command("hug", "Just hug someone.") +@lightbulb.set_help("Hug someone you mention.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member) +@lightbulb.command("hug") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_hug(ctx: lightbulb.context) -> None: target = ctx.options.member gif = get_gif("anime-hug") - await action(ctx, f"**{ctx.member.username}** hug to **{target.username}**", gif) + await action(ctx, f"**{ctx.member.username}** hugs **{target.username}**", gif) ## Claps for person mentioned @funPlugin.command -@lightbulb.set_help("Clap or clap for someone.") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) -@lightbulb.command("clap", "Just clap or clap for someone.") +@lightbulb.set_help("Clap or clap for someone you mention.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) +@lightbulb.command("clap") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_clap(ctx: lightbulb.context) -> None: @@ -149,22 +149,22 @@ async def command_clap(ctx: lightbulb.context) -> None: ## High fives person mentioned @funPlugin.command -@lightbulb.set_help("Highfive to the person who mentions.") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) -@lightbulb.command("highfive", "Highfive to someone :)") +@lightbulb.set_help("Highfives someone you mention.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member) +@lightbulb.command("highfive") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_highfive(ctx: lightbulb.context) -> None: target = ctx.options.member gif = get_gif("anime-highfive") - await action(ctx, f"**{ctx.member.username}** highfive to **{target.username}**", gif) + await action(ctx, f"**{ctx.member.username}** highfives **{target.username}**", gif) ## Laugh at someone mentioned @funPlugin.command -@lightbulb.set_help("Laugh or tease someone you mention") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) -@lightbulb.command("laugh", "Laugh or tease.") +@lightbulb.set_help("Laugh yourself or at someone you mention.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) +@lightbulb.command("laugh") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_laugh(ctx: lightbulb.context) -> None: @@ -179,8 +179,8 @@ async def command_laugh(ctx: lightbulb.context) -> None: ## Kiss the person mentioned @funPlugin.command -@lightbulb.set_help("Kiss the person who mentions.") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member) +@lightbulb.set_help("Kiss the person you mention.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member) @lightbulb.command("kiss", "Kiss someone.") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_kiss(ctx: lightbulb.context) -> None: @@ -190,20 +190,20 @@ async def command_kiss(ctx: lightbulb.context) -> None: return gif = get_gif("anime-kiss") - await action(ctx, f"**{ctx.member.username}** le dio un beso a **{target.username}**. (づ ̄ ³ ̄)づ", gif) + await action(ctx, f"**{ctx.member.username}** kisses **{target.username}**.", gif) ## Code grind @funPlugin.command -@lightbulb.set_help("Show you are changing the world whit code.") -@lightbulb.option("member", "The member you choice for make the action.", hikari.Member, required=False) -@lightbulb.command("grind", "Programming alone or with someone.") +@lightbulb.set_help("Hitting the programmer grind, alone or with someone mentioned.") +@lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) +@lightbulb.command("grind") @lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) async def command_program(ctx: lightbulb.context) -> None: target = ctx.options.member gif = get_gif("anime-programmer", limit=3) if target == None: - await action(ctx, f"**{ctx.member.username}** is programming something amazing.", gif) + await action(ctx, f"**{ctx.member.username}** is hitting the programmer grind.", gif) else: await action(ctx, f"**{ctx.member.username}** is programming something amazing with **{target.username}**", gif) @@ -260,4 +260,10 @@ async def dice(ctx: lightbulb.context.Context) -> None: " + ".join(f"{r}" for r in rolls) + (f" + {bonus} (bonus)" if bonus else "") + f" = **{sum(rolls) + bonus:,}**" - ) \ No newline at end of file + ) + +def load(bot: lightbulb.BotApp) -> None: + bot.add_plugin(funPlugin) + +def unload(bot: lightbulb.BotApp) -> None: + bot.remove_plugin(funPlugin) \ No newline at end of file From 7d6a31f78a253ae380215ec71681dfc01ac76231 Mon Sep 17 00:00:00 2001 From: b1gdipper Date: Mon, 24 Jan 2022 10:06:30 +0530 Subject: [PATCH 9/9] Fixed errors in plugins --- hawkeye/core/plugins/common/fun.py | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/hawkeye/core/plugins/common/fun.py b/hawkeye/core/plugins/common/fun.py index 9554609..2d5e4a3 100644 --- a/hawkeye/core/plugins/common/fun.py +++ b/hawkeye/core/plugins/common/fun.py @@ -15,8 +15,8 @@ @lightbulb.set_help("Give answers to your questions.") @lightbulb.option("question", "The question you want answers to.") @lightbulb.command("8ball", description="Make the game of the 8ball.") -@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand) -async def cmd_ball(ctx: lightbulb.SlashContext): +@lightbulb.implements(lightbulb.PrefixCommand) +async def ball(ctx: lightbulb.Context): responses = [ "It is certain.", @@ -49,8 +49,8 @@ async def cmd_ball(ctx: lightbulb.SlashContext): @lightbulb.add_cooldown(length=3600, uses=1, bucket=lightbulb.UserBucket) @lightbulb.option("user", "User you want give the cookie", hikari.Member) @lightbulb.command(name="givecookie", aliases=("gcookie",), description="Give a cookie to a user.") -@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand) -async def cmd_cookie(ctx: lightbulb.SlashContext) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def cookie(ctx: lightbulb.Context) -> None: target = ctx.options.user @@ -122,8 +122,8 @@ async def action(ctx: lightbulb.Context, text, image) -> None: @lightbulb.set_help("Hug someone you mention.") @lightbulb.option("member", "The member chosen for action.", hikari.Member) @lightbulb.command("hug") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_hug(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def hug(ctx: lightbulb.Context) -> None: target = ctx.options.member gif = get_gif("anime-hug") @@ -134,8 +134,8 @@ async def command_hug(ctx: lightbulb.context) -> None: @lightbulb.set_help("Clap or clap for someone you mention.") @lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) @lightbulb.command("clap") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_clap(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def clap(ctx: lightbulb.Context) -> None: target = ctx.options.member @@ -152,8 +152,8 @@ async def command_clap(ctx: lightbulb.context) -> None: @lightbulb.set_help("Highfives someone you mention.") @lightbulb.option("member", "The member chosen for action.", hikari.Member) @lightbulb.command("highfive") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_highfive(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def command_highfive(ctx: lightbulb.Context) -> None: target = ctx.options.member @@ -165,8 +165,8 @@ async def command_highfive(ctx: lightbulb.context) -> None: @lightbulb.set_help("Laugh yourself or at someone you mention.") @lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) @lightbulb.command("laugh") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_laugh(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def command_laugh(ctx: lightbulb.Context) -> None: target = ctx.options.member @@ -182,8 +182,8 @@ async def command_laugh(ctx: lightbulb.context) -> None: @lightbulb.set_help("Kiss the person you mention.") @lightbulb.option("member", "The member chosen for action.", hikari.Member) @lightbulb.command("kiss", "Kiss someone.") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_kiss(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def command_kiss(ctx: lightbulb.Context) -> None: target = ctx.options.member if target.id == ctx.member.id: await ctx.respond(f"I don't think you can kiss yourself {ctx.member.mention}") @@ -197,8 +197,8 @@ async def command_kiss(ctx: lightbulb.context) -> None: @lightbulb.set_help("Hitting the programmer grind, alone or with someone mentioned.") @lightbulb.option("member", "The member chosen for action.", hikari.Member, required=False) @lightbulb.command("grind") -@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand) -async def command_program(ctx: lightbulb.context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def command_program(ctx: lightbulb.Context) -> None: target = ctx.options.member gif = get_gif("anime-programmer", limit=3) @@ -212,8 +212,8 @@ async def command_program(ctx: lightbulb.context) -> None: @funPlugin.command @lightbulb.option('fahrenheit', 'Temperature in Fahrenheit to convert.', required=True, type=float) @lightbulb.command('celsius', 'Convert Fahrenheit to Celsius.') -@lightbulb.implements(lightbulb.commands.SlashCommand) -async def celsius_command(ctx: lightbulb.context.Context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def celsius_command(ctx: lightbulb.Context) -> None: await ctx.respond( embed=hikari.Embed( title='Fahrenheit to Celsius', @@ -225,8 +225,8 @@ async def celsius_command(ctx: lightbulb.context.Context) -> None: @funPlugin.command @lightbulb.option('celsius', 'Temperature in Celsius to convert.', required=True, type=float) @lightbulb.command('fahrenheit', 'Convert Celsius to Fahrenheit.') -@lightbulb.implements(lightbulb.commands.SlashCommand) -async def fahrenheit_command(ctx: lightbulb.context.Context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def fahrenheit_command(ctx: lightbulb.Context) -> None: await ctx.respond( embed=hikari.Embed( title='Celsius to Fahrenheit', @@ -241,8 +241,8 @@ async def fahrenheit_command(ctx: lightbulb.context.Context) -> None: @lightbulb.option("sides", "The number of sides each die will have.", int, default=6) @lightbulb.option("number", "The number of dice to roll.", int) @lightbulb.command("dice", "Roll one or more dice.") -@lightbulb.implements(commands.SlashCommand) -async def dice(ctx: lightbulb.context.Context) -> None: +@lightbulb.implements(lightbulb.PrefixCommand) +async def dice(ctx: lightbulb.Context) -> None: number = ctx.options.number sides = ctx.options.sides bonus = ctx.options.bonus