From 406577e2f577029152e3be3dfd9eade8c6d10f28 Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Thu, 18 Aug 2022 16:15:04 -0300 Subject: [PATCH 1/4] ADD: Quote count command --- utils/commands.py | 17 ++++++++++++++++- utils/database.py | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/utils/commands.py b/utils/commands.py index 107fbdf..9561b8d 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -6,7 +6,7 @@ from random import choice from discord.ext import commands -from utils.database import get_by_id, get_quotes, remove_quote, set_quote +from utils.database import get_by_id, get_quotes, remove_quote, set_quote, count_quotes client = commands.Bot(command_prefix='--') logger = logging.getLogger(__name__) @@ -134,3 +134,18 @@ async def queue_stack(bot: object) -> str: """ return await bot.send('A list of the 5 latest message IDs follows:'\ f' `{",".join(str(q) for q in quote_id_stack[-5:])}`') + +@client.command(aliases=['cq', 'cquotes']) +async def quote_count(bot: object) -> str: + """ + Outputs a quote count from the database + """ + + # For len(amount) to work, first it needs to be converted into str + amount = count_quotes() + amount = str(amount) + amount = amount[1:len(amount)][:-2] + + msg = "Quote count: `" + amount + "`" + + return await bot.send(msg) \ No newline at end of file diff --git a/utils/database.py b/utils/database.py index a74f808..f73a133 100644 --- a/utils/database.py +++ b/utils/database.py @@ -123,3 +123,17 @@ def remove_quote(_id: int) -> bool: return True except Exception: return False + +def count_quotes() -> int: + """ + Counts the amount of quotes in the database + """ + _sql = f''' + select count(*) from neeble_quotes + ''' + + with Cursor(MYSQL_CONFIG) as cursor: + cursor.execute(_sql) + count = cursor.fetchone() + + return count \ No newline at end of file From 7c3be7586b643ec3ca54da70a9dbcb418429ce66 Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Thu, 18 Aug 2022 16:17:37 -0300 Subject: [PATCH 2/4] CHANGE: Fixed the grammar on the help tab --- utils/commands.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/utils/commands.py b/utils/commands.py index 9561b8d..8ed836c 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -16,10 +16,10 @@ quote_id_stack = [] @client.command(aliases=['q']) async def quote(bot: object, *quote: str) -> str: """ - Save a quote into database. + Saves a quote into the database. """ if not quote: - return await bot.send('You\'re not my mute uncle, tell me something to remember.\n(You have\'nt provided a quote') + return await bot.send('You\'re not my mute uncle, tell me something to remember.\n(You haven\'t provided a quote)') quote = ' '.join(quote) @@ -39,7 +39,7 @@ async def quote(bot: object, *quote: str) -> str: @client.command(aliases=['rq']) async def random_quote(bot: object) -> str: """ - Get an random quote from database. + Get a random quote from the database. """ quotes = get_quotes(quote_id_stack) stack_limit = int((len(quotes) * .25)) @@ -49,7 +49,7 @@ async def random_quote(bot: object) -> str: quote_id_stack.pop(0) quotes = get_quotes(quote_id_stack) elif not quotes: - return await bot.send('You\'ve got no quotes saved yet.\n(Save quotes by using `--q str: @client.command(aliases=['qid']) async def by_id(bot, _id: int=None) -> str: """ - Get quote by ID. + Gets one quote by ID. """ syntax = "`--qid `" if not _id: - return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to quote it to you!?_\n(The correct syntax is " + syntax ) + return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to quote it to you!?_\n(The correct syntax is " + syntax + ")") if not isinstance(_id, int): - return await bot.send("_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is " + syntax) + return await bot.send("_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is " + syntax + ")") quote = get_by_id(_id) if not quote: - return await bot.send("_Wrong ID, sucker!_\n(There's no such quote with id " + _id) + return await bot.send("_Wrong ID, sucker!_\n(There's no such quote with id " + _id + ")") try: # To image links. @@ -98,7 +98,7 @@ async def by_id(bot, _id: int=None) -> str: @client.command(aliases=['dq']) async def delete_quote(bot, _id: int=None) -> str: """ - Delete one quote by database ID. + Deletes one quote by ID. """ syntax = "`--dq `" roles = [r.name for r in bot.author.roles] @@ -108,13 +108,13 @@ async def delete_quote(bot, _id: int=None) -> str: "(You don't have the necessary role for this command") if not _id: - return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to delete it to you!?_\n(The correct syntax is " + syntax ) + return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to delete it to you!?_\n(The correct syntax is " + syntax + ")") if not isinstance(_id, int): - return await bot.send("_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is " + syntax) + return await bot.send("_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is " + syntax + ")") quote = get_by_id(_id) - + if not quote: return await bot.send("_Wrong ID, sucker!_\n(There's no such quote with id " + _id) From b67c822cf125a002fe42e83a72f669be814e919b Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Thu, 18 Aug 2022 16:53:03 -0300 Subject: [PATCH 3/4] ADD: Version banner --- motd | 11 +++++++++++ utils/commands.py | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 motd diff --git a/motd b/motd new file mode 100644 index 0000000..e287e55 --- /dev/null +++ b/motd @@ -0,0 +1,11 @@ + ▄▄ ▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄ +█ █ █ █ █ █ ▄ █ █ █ █ +█ █▄█ █ ▄▄▄█ ▄▄▄█ █▄█ █ █ █ ▄▄▄█ +█ █ █▄▄▄█ █▄▄▄█ █ █ █ █▄▄▄ +█ ▄ █ ▄▄▄█ ▄▄▄█ ▄ ██ █▄▄▄█ ▄▄▄█ +█ █ █ █ █▄▄▄█ █▄▄▄█ █▄█ █ █ █▄▄▄ +█▄█ █▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ +Neeble version: 1.1 +You can help the development of neeble in +https://github.com/KevinCaires/neeble +Thank you! \ No newline at end of file diff --git a/utils/commands.py b/utils/commands.py index 8ed836c..ea6db3c 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -105,7 +105,7 @@ async def delete_quote(bot, _id: int=None) -> str: if not 'Operador' in roles: return await bot.send("_And who the fuck do **YOU** think you are!?_.\n"\ - "(You don't have the necessary role for this command") + "(You don't have the necessary role for this command)") if not _id: return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to delete it to you!?_\n(The correct syntax is " + syntax + ")") @@ -148,4 +148,24 @@ async def quote_count(bot: object) -> str: msg = "Quote count: `" + amount + "`" + return await bot.send(msg) + +@client.command(aliases=['v', 'version']) +async def info(bot: object) -> str: + """ + Displays the bot's information + """ + roles = [r.name for r in bot.author.roles] + + if not 'Operador' in roles: + return await bot.send("_And who the fuck do **YOU** think you are!?_.\n"\ + "(You don't have the necessary role for this command)") + + motd = open("./motd", mode='r') + text = motd.readlines() + fullbanner = "" + for lines in text: + fullbanner = fullbanner + lines + msg = f'''```\n''' + fullbanner + f'''\n```''' + return await bot.send(msg) \ No newline at end of file From da6e19234fa02176d445f537f96f146356a962cf Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Thu, 18 Aug 2022 16:59:58 -0300 Subject: [PATCH 4/4] CHANGE: I forgot to close the parenthesis, and so did Kevin --- utils/commands.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/commands.py b/utils/commands.py index e709ebd..ce0c26c 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -75,10 +75,10 @@ async def by_id(bot, _id: int=None) -> str: syntax = "`--qid `" if not _id: - return await bot.send(f"_If you don't tell me the ID, how the fuck do you expect me to quote it to you!?_\n(The correct syntax is {syntax}") + return await bot.send(f"_If you don't tell me the ID, how the fuck do you expect me to quote it to you!?_\n(The correct syntax is {syntax})") if not isinstance(_id, int): - return await bot.send(f"_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is {syntax}") + return await bot.send(f"_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is {syntax})") quote = get_by_id(_id) @@ -108,10 +108,10 @@ async def delete_quote(bot, _id: int=None) -> str: "(You don't have the necessary role for this command)") if not _id: - return await bot.send(f"_If you don't tell me the ID, how the fuck do you expect me to delete it to you!?_\n(The correct syntax is {syntax}") + return await bot.send(f"_If you don't tell me the ID, how the fuck do you expect me to delete it to you!?_\n(The correct syntax is {syntax})") if not isinstance(_id, int): - return await bot.send(f"_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is {syntax}") + return await bot.send(f"_Don't fuck with me, you asshole. The ID needs to be an interger!_\n(The correct syntax is {syntax})") quote = get_by_id(_id)