-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcravebot.py
61 lines (43 loc) · 1.5 KB
/
cravebot.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# bot.py
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
#### Chargement
@client.event
async def on_ready():
for guild in client.guilds:
if guild.name == GUILD:
break
print(
f'{client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})\n'
)
members = '\n - '.join([member.name for member in guild.members])
print(f'Guild Members:\n - {members}')
print("Nombre de joueurs : "+str(len(guild.members)))
##### Evenement nouveau joueur
@client.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Yooo {member.name}, Bienvenue sur peaceandcube, moi je suis Cravebot!'
)
print(member.name+" vient de rejoindre le serveur.")
##### Evenement message salon/mp
@client.event
async def on_message(message):
if message.author == client.user:
return
if 'peace' in message.content.lower():
await message.channel.send('Ouais bien dit ça! Peace')
print(str(message.author) + " a declenché le mot peace")
if 'fdp' in message.content.lower():
await message.channel.send('Oulalala le langage !!!')
print(str(message.author) + " a declenché le mot fdp")
client.run(TOKEN)