Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (60 loc) · 2.63 KB
/
Copy pathmain.py
File metadata and controls
70 lines (60 loc) · 2.63 KB
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
62
63
64
65
66
67
68
69
import discord
from discord.ext import commands
import asyncio
import os
import json
import random
import tasks
import datetime
bot = commands.Bot(command_prefix='pilote.', self_bot=True)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
await bot.change_presence(status=discord.Status.dnd)
while True:
server_id = 1103936072989278279
server = bot.get_guild(server_id)
if server is not None:
member_count = server.member_count
bot_user = await bot.fetch_user(bot.user.id)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f'{member_count} membres'))
await asyncio.sleep(60)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f'.gg/PILOTE'))
await asyncio.sleep(60)
from discord.ext import tasks
loops = {}
@bot.command()
async def sendloop(ctx, time_loop: int, *, message: str):
if ctx.author.id == 97285029289275392:
if ctx.channel.id not in loops:
loops[ctx.channel.id] = send_message_loop(time_loop)
loops[ctx.channel.id].start(ctx, message)
await ctx.send(f"Ok.")
else:
await ctx.send("Non.")
else:
return
def send_message_loop(time_loop):
@tasks.loop(seconds=time_loop)
async def inner(ctx, message):
await ctx.send(message)
return inner
@bot.command()
async def stoploop(ctx):
if ctx.author.id == 97285029289275392:
if ctx.channel.id in loops and loops[ctx.channel.id].is_running():
loops[ctx.channel.id].cancel()
del loops[ctx.channel.id]
await ctx.send("Ok.")
else:
await ctx.send("Non jsp.")
else:
return
#####################################################################################################################
# #
# #
# TOKEN DU BOT #
# PAR PILOTE PRODUCTION #
# #
#####################################################################################################################
bot.run("YOUR TOKEN HERE", bot=False)