code for part3
This commit is contained in:
parent
a9a962825c
commit
6b9f25d052
24
main.py
24
main.py
@ -1,29 +1,33 @@
|
|||||||
import os
|
import os
|
||||||
import discord
|
import discord
|
||||||
|
from discord.commands import Option
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True # NOQA
|
intents.message_content = True # NOQA
|
||||||
|
|
||||||
bot = discord.Bot(intents=intents)
|
bot = discord.Bot(intents=intents, debug_guilds=[889424923859230720])
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"{bot.user} ist online")
|
print(f"{bot.user} ist online")
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.slash_command(description="Grüße einen User")
|
||||||
async def on_message(msg):
|
async def greet(ctx, user: Option(discord.User, "Der User, den du grüßen möchtest")):
|
||||||
if msg.author.bot:
|
await ctx.respond(f"Hallo {user.mention}")
|
||||||
return
|
|
||||||
|
|
||||||
await msg.channel.send("Du stinkst")
|
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.slash_command(description="Lass den Bot eine Nachricht senden")
|
||||||
async def on_message_delete(msg):
|
async def say(
|
||||||
await msg.channel.send(f"Eine Nachricht von {msg.author} wurde gelöscht: {msg.content}")
|
ctx,
|
||||||
|
text: Option(str, "Der Text, den du senden möchtest"),
|
||||||
|
channel: Option(discord.TextChannel, "Der Channel, in den du die Nachricht senden möchtest")
|
||||||
|
):
|
||||||
|
await channel.send(text)
|
||||||
|
await ctx.respond("Nachricht gesendet", ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
bot.run(os.getenv("DISCORD_TOKEN"))
|
bot.run(os.getenv("DISCORD_TOKEN"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user