First Commit
This commit is contained in:
44
Aufgaben/Basic-Bot.py
Normal file
44
Aufgaben/Basic-Bot.py
Normal 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('')
|
||||||
Reference in New Issue
Block a user