-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscord.py
40 lines (30 loc) · 1.02 KB
/
Discord.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Connecté en tant que {bot.user}')
@bot.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.text_channels, name='général')
if channel:
await channel.send(f'Bienvenue {member.mention} sur le serveur !')
@bot.event
async def on_member_remove(member):
channel = discord.utils.get(member.guild.text_channels, name='général')
if channel:
await channel.send(f'{member.mention} a quitté le serveur.')
@bot.command()
async def hello(ctx):
await ctx.send('Salut !')
@bot.command()
async def ping(ctx):
await ctx.send(f'Pong ! {round(bot.latency * 1000)}ms')
@bot.command()
async def serveur(ctx):
await ctx.send(f'Nom du serveur : {ctx.guild.name}\nNombre de membres : {ctx.guild.member_count}')
bot.run('TOKEN')