From b7db925a10675882961311e09cf858b015276d74 Mon Sep 17 00:00:00 2001 From: Lukas Blacha Date: Fri, 3 Feb 2023 14:41:24 +0100 Subject: [PATCH] First Commit --- Aufgaben/Basic-Bot.py | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Aufgaben/Basic-Bot.py diff --git a/Aufgaben/Basic-Bot.py b/Aufgaben/Basic-Bot.py new file mode 100644 index 0000000..db17f78 --- /dev/null +++ b/Aufgaben/Basic-Bot.py @@ -0,0 +1,44 @@ +import discord +from discord.ext import commands +import os + +description = """ +An example bot to showcase the discord.ext.commands extension module. +There are a number of utility commands being showcased here. +""" + +intents = discord.Intents.default() +intents.members = True +intents.message_content = True + +bot = commands.Bot( + command_prefix=commands.when_mentioned_or("!"), + description=description, + intents=intents) + +@bot.event +async def on_ready(): + print(f"Logged in as {bot.user} (ID: {bot.user.id})") + print("------") + + +@bot.command() +async def add(ctx: commands.Context, left: int, right: int): + """Adds two numbers together.""" + await ctx.send(str(left + right)) + + +@bot.command() +async def calc(ctx: commands.Context, left: int, opper: str, right: int): + if opper == "+": + await ctx.send(str(left + right)) + elif opper == "-": + await ctx.send(str(left - right)) + elif opper == "*": + await ctx.send(str(left * right)) + elif opper == "/": + await ctx.send(str(left / right)) + else: + await ctx.send(f"Bitte überprüfe deine Eingabe! `{opper}` ist kein gültiger Operand") + +bot.run('')