Compare commits
No commits in common. "cc02629af2bddf281b5cfabf3e4f4962649ff47d" and "871479f7968472a7d70414d85983086ba7002924" have entirely different histories.
cc02629af2
...
871479f796
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
.venv/
|
.venv/
|
||||||
venv/
|
venv/
|
||||||
.idea/*
|
.idea/*
|
||||||
__pycache__/
|
|
||||||
@ -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))
|
|
||||||
10
main.py
10
main.py
@ -6,7 +6,6 @@ from dotenv import load_dotenv
|
|||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True # NOQA
|
intents.message_content = True # NOQA
|
||||||
intents.members = True # NOQA
|
|
||||||
|
|
||||||
bot = discord.Bot(intents=intents, debug_guilds=[889424923859230720])
|
bot = discord.Bot(intents=intents, debug_guilds=[889424923859230720])
|
||||||
|
|
||||||
@ -56,10 +55,5 @@ async def info(
|
|||||||
|
|
||||||
await ctx.respond(embed=embed)
|
await ctx.respond(embed=embed)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
load_dotenv()
|
||||||
for filename in os.listdir("cogs"):
|
bot.run(os.getenv("DISCORD_TOKEN"))
|
||||||
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