Compare commits

..

No commits in common. "main" and "Part3" have entirely different histories.
main ... Part3

4 changed files with 3 additions and 75 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
.venv/
venv/
.idea/*
__pycache__/

View File

@ -3,5 +3,3 @@ https://www.youtube.com/watch?v=PAsRoedhyOU&list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjd
https://github.com/tibue99/tutorial-bot
https://github.com/Pycord-Development

View File

@ -1,37 +0,0 @@
# 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
View File

@ -6,7 +6,6 @@ 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])
@ -30,36 +29,5 @@ 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"))