1
0

First Commit

This commit is contained in:
Lukas Blacha
2023-02-03 14:41:24 +01:00
parent e2b3c636ac
commit b7db925a10

44
Aufgaben/Basic-Bot.py Normal file
View File

@@ -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('')