Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc02629af2 | |||
| 3778e3e203 | |||
| 871479f796 | |||
| b135e1e949 | |||
| 0245f24f7b | |||
| 0d894a06dd |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.venv/
|
||||
venv/
|
||||
.idea/*
|
||||
__pycache__/
|
||||
@ -3,3 +3,5 @@ https://www.youtube.com/watch?v=PAsRoedhyOU&list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjd
|
||||
|
||||
https://github.com/tibue99/tutorial-bot
|
||||
|
||||
|
||||
https://github.com/Pycord-Development
|
||||
37
cogs/say_hallo.py
Normal file
37
cogs/say_hallo.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Für dieses Beispiel muss der Server Member Intent im Dev Portal und in der Main-Datei aktiviert sein
|
||||
#
|
||||
# intents = discord.Intents.default()
|
||||
# intents.members = True
|
||||
#
|
||||
# bot = discord.Bot(
|
||||
# intents=intents,
|
||||
# debug_guilds=[123456789], # hier server id einfügen
|
||||
# )
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.commands import slash_command
|
||||
|
||||
|
||||
class Base(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@slash_command()
|
||||
async def say_hallo(self, ctx):
|
||||
await ctx.respond(f"Hey {ctx.author.mention}")
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_member_join(self, member):
|
||||
embed = discord.Embed(
|
||||
title="Willkommen",
|
||||
description=f"Hey {member.mention}",
|
||||
color=discord.Color.orange()
|
||||
)
|
||||
|
||||
channel = await self.bot.fetch_channel(123456789) # hier channel id einfügen
|
||||
await channel.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Base(bot))
|
||||
32
main.py
32
main.py
@ -6,6 +6,7 @@ from dotenv import load_dotenv
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True # NOQA
|
||||
intents.members = True # NOQA
|
||||
|
||||
bot = discord.Bot(intents=intents, debug_guilds=[889424923859230720])
|
||||
|
||||
@ -29,5 +30,36 @@ async def say(
|
||||
await ctx.respond("Nachricht gesendet", ephemeral=True)
|
||||
|
||||
|
||||
@bot.slash_command(name="userinfo", description="Zeige Infos über einen User")
|
||||
async def info(
|
||||
ctx,
|
||||
alter: Option(int, "Das Alter", min_value=1, max_value=99),
|
||||
user: Option(discord.Member, "Gib einen User an", default=None),
|
||||
):
|
||||
if user is None:
|
||||
user = ctx.author
|
||||
|
||||
embed = discord.Embed(
|
||||
title=f"Infos über {user.name}",
|
||||
description=f"Hier siehst du alle Details über {user.mention}",
|
||||
color=discord.Color.blue()
|
||||
)
|
||||
|
||||
time = discord.utils.format_dt(user.created_at, "R")
|
||||
|
||||
embed.add_field(name="Account erstellt", value=time, inline=False)
|
||||
embed.add_field(name="ID", value=user.id)
|
||||
embed.add_field(name="Alter", value=alter)
|
||||
|
||||
embed.set_thumbnail(url=ctx.author.display_avatar.url)
|
||||
embed.set_footer(text="Das ist ein Footer")
|
||||
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
if __name__ == "__main__":
|
||||
for filename in os.listdir("cogs"):
|
||||
if filename.endswith(".py"):
|
||||
bot.load_extension(f"cogs.{filename[:-3]}")
|
||||
|
||||
load_dotenv()
|
||||
bot.run(os.getenv("DISCORD_TOKEN"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user