commit 1ba4aad40396f03bd6fa782b761c83d4c83bf28d Author: ggodot Date: Tue Jan 7 00:22:44 2025 +0100 starting with slash commands diff --git a/wikibot.py b/wikibot.py new file mode 100644 index 0000000..3c47b56 --- /dev/null +++ b/wikibot.py @@ -0,0 +1,36 @@ +import discord, wikipedia +from discord import Option +#from private.config import token + + +#import os +#os.chdir("/opt/disbot") + +bot = discord.Bot() +g_ids = [1261698917163077632] + +@bot.event +async def on_ready(): + print(f"We've logged in as {bot.user}.") + + +@bot.slash_command(guild_ids=g_ids, name = "summary", description="Returns a Wikipedia summary" ) +async def summary(ctx, search: Option(str, description="What do you want to get summary for?", required = True)): + await ctx.channel.trigger_typing() # shows that bot is typing + try: # sezene sumar a odesle + thesummary = wikipedia.summary(search, chars = 1950) + try: + await ctx.respond(thesummary) # Respons je limitovano 3 vterinami, lepsi ale obcas nestihne + except: + await ctx.send(thesummary) # Send horsi, pouzije pokud nestihne response + except: # pokud nesezena musi vyhledavat + searchsummary = str(wikipedia.search(search, suggestion = True)).replace('(', '').replace(")", "").replace("'", "").replace('[', '').replace(']', '') + try: + await ctx.respond(f"I can't seem to find a summary for that.. DId you mean: {searchsummary}") + except: + await ctx.send(f"I can't seem to find a summary for that.. DId you mean: {searchsummary}") + + + + +bot.run("MTMyNTk1Mzg4OTcyNzQxNDM0Mw.G2Tgo0.2OhbgaVYhys0BhxJMVgGDnG0W5qvxH-soJML3M")