From 82e35badba879893916e017f26cde2266f934dfa Mon Sep 17 00:00:00 2001 From: Honza Date: Fri, 15 Mar 2024 16:02:57 +0100 Subject: [PATCH] progressed --- bot_newest_version/susmain3.py | 71 ++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/bot_newest_version/susmain3.py b/bot_newest_version/susmain3.py index b100bc6..780e7bf 100644 --- a/bot_newest_version/susmain3.py +++ b/bot_newest_version/susmain3.py @@ -48,7 +48,6 @@ async def word_counter(message): #counts words in word list # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # async def count_reader(message): #count command returns message with counts of certain word of all users - message = message.message obsah = message.content.lower().split(' ') files = [] user_counts = [] @@ -111,7 +110,7 @@ async def count_reader(message): #count command returns message w # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def primenum_event(message): #primenumbers script +async def primenum_command(message): #primenumbers script vstup = int(message.content.split("~primenum ",1)[1]) @@ -158,7 +157,7 @@ async def primenum_event(message): #primenumbers script # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def scprove_event(message): #scientists prove that... script +async def scprove_command(message): #scientists prove that... script input_message = str(message.content.split('~scprove',1)[1]) @@ -171,22 +170,34 @@ async def scprove_event(message): #scientists prove that... scri # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def help_event(message): #help script - cc = '' - ff = '' - for C in command_list.values(): - cc = cc + C.help_print() - for C in function_list.values(): - ff = ff + C.help_print() - final_message = '**__Commands__:**\n' + cc + '**__Functions__:**\n' + ff - await message.channel.send(final_message) +async def help_command(message): #help script + embed = discord.Embed(title = "susbot" ,description = "Here is list of my commands and functions", colour=discord.Colour.red) + embed.set_author(name=client.user) + embed.add_field(name="Commands", inline = False) + embed.add_field(name="~help", value="Command that will show you this list", inline = True) + embed.add_field(name="~etime", value="Command that will tell you the time :)", inline = True) + embed.add_field(name="~scprove", value="Scientist will prove you anything: ~scprove ", inline = True) + embed.add_field(name="~primenum", value="Bot will tell you if number is a prime number", inline = True) + embed.add_field(name="~count", value="Ask for word count of users: ~count ", inline = True) + + return(embed) + +# cc = '' +# ff = '' +# for C in command_list.values(): +# cc = cc + C.help_print() +# for C in function_list.values(): +# ff = ff + C.help_print() +# final_message = '**__Commands__:**\n' + cc + '**__Functions__:**\n' + ff +# await message.channel.send(final_message) + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def etime_event(message): #epoch time script +async def etime_command(message): #epoch time script await message.channel.send(time.time()) # @@ -194,7 +205,7 @@ async def etime_event(message): #epoch time script # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def greetings_function(message): #greetings function +async def greetings_function(message): #greetings function global t_h if t_h + 30 < time.time(): for g in greetings: @@ -212,7 +223,7 @@ async def greetings_function(message): #greetings function # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -async def sus_function(message): #sus function +async def sus_function(message): #sus function global t_s if t_s + 20 < time.time(): if ('sus') in (message.content).lower() and message.content[0] != '~': @@ -256,13 +267,13 @@ function_list['counter'] = Function(' word counter', ' --> Bot counts how man command_list = {} -command_list['~etime'] = Command('~etime', ' --> Command that will tell you epoch time\n', etime_event) +command_list['~etime'] = Command('~etime', ' --> Command that will tell you epoch time\n', etime_command) -command_list['~help'] = Command('~help', ' --> Command that will show you this list\n', help_event) +command_list['~help'] = Command('~help', ' --> Command that will show you this list\n', help_command) -command_list['~primenum'] = Command('~primenum', ' --> Bot will tell you if number is a prime number (number of six digits max.)\n', primenum_event) +command_list['~primenum'] = Command('~primenum', ' --> Bot will tell you if number is a prime number (number of six digits max.)\n', primenum_command) -command_list['~scprove'] = Command('~scprove', ' --> Scientist will prove you anything: |*~scprove *|\n', scprove_event) +command_list['~scprove'] = Command('~scprove', ' --> Scientist will prove you anything: |*~scprove *|\n', scprove_command) command_list['~count'] = Command('~count', ' --> Ask for word count of users: |*~count *|\n\n', count_reader) @@ -297,12 +308,24 @@ async def on_message(message): @client.command() async def count(ctx): - await ctx.send("jo") - await count_reader(ctx) + await count_reader(ctx.message) + +@client.command() +async def help(ctx): + await ctx.send(help_command(ctx.message)) + +@client.command() +async def etime(ctx): + await etime_command(ctx.message) + +@client.command() +async def primenum(ctx): + await primenum_command(ctx.message) + +@client.command() +async def scprove(ctx): + await scprove_command(ctx.message) -# -# -# #accesing functions and commands hub to run commands # if message.content.startswith('~'): # for cmd in command_list.keys():