Skip to content

Instantly share code, notes, and snippets.

@Zian25
Last active January 24, 2022 14:01
Show Gist options
  • Save Zian25/bfeab5ab60ad1d604f1d73c2b31cd5c8 to your computer and use it in GitHub Desktop.
Save Zian25/bfeab5ab60ad1d604f1d73c2b31cd5c8 to your computer and use it in GitHub Desktop.
# -*- coding:utf-8 -*-
import discord
import asyncio
from discord.ext import commands, tasks
client = discord.Client()
# Aqui começa o Loop, que envia mensagem automatica para um determinado canal
async def anuncio():
while True:
# É importante usar o Asyncio, pois cria um thread paralelo e se restringe apenas ao thread
# Se usássemos o modulo sleep "time.sleep(tempo)" ele pararia o processo inteiro até o tempo chegar
# use await asyncio.sleep(tempo em segundos), 10800 = 3 horas
await asyncio.sleep(10800)
canal = client.get_channel(ID DO CANAL)
await canal.send("Mensagem automatica para enviar")
# Aqui criamos um loop restrito apenas ao "anuncio", ou seja, não interfere nas outras tarefas
client.loop.create_task(anuncio())
client.run('TOKEN DO BOT')
@megavapor
Copy link

nao consegui fazer rodar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment