CSUL Discord Bot

Overview

Cruzeiro

This is the same old bot running on the Discord Server of CSUL, but i've changed the code. It's better now.

How i did

The bot is now running on Heroku servers, using only free features. There are some new commands on Heroku CLI that can be a problem if you don't pay attention. I'll list some things i almost miss while read the documentations, on the first attempt to host this bot.

→ Create Python reference

  • Heroku won't able the buildpacks if they don't be referred. I used heroku buildpacks:set heroku/python to set it.
  • This can be configurated at the heroku create command, creating the app and setting the buildpack inside.

→ Set Procfile and requirements

  • These two files must be created at the same directory as the .py script. The Procfile can't have a extension, and will contain the web/worker dynos to actually connect the app to Heroku.
  • I downloaded gunicorn to use these dynos properly, but i don't really needed it at all. All i had to do was run the dynos with the python parameter.

Procfile

  • The requirements.txt has to contain all the packages/versions that are being used on the application. I also forgot to put a "discord==1.0.1" line to invoke the main discord package.
  • On Heroku CLI, i had to make a heroku ps:scale web=1 worker=1 after update the Procfile. This line sets the amount of dynos that the application will use. Also, i had to enable the options of web and worker (after commit) on Heroku dashboard resources page.

Heroku Resources

→ Switch branches and deploy

  • Yes, i was in the remote branch master, which was used to be the default branch for Heroku. However, i had to change it to the main branch, using the command line git checkout main. After doing this, the code was able to actually being pushed.
  • The code i edit is on master branch (Github), i just switch to main everytime i need to push it to Heroku. So, the first time i deployed, the bot was pinging each 30 seconds, and logging twice. The problem here was the unnecessary use of gunicorn, which runs a new server online, so i just had to remove the line reference "web: gunicorn main:app" of the Procfile, replacing by the python main.py that was mentioned before. I've added the worker dyno, edited some lines of the code and pushed it. The bot is on, working fine.

Online

I'll update every change or issue on the application, this .readme just tells the things i did to solve some problems. If there's something that can be changed or solved in a better way, i can edit the text anytime, so it can be helpful to others.

Texto em Português

Cruzeiro

Esse é o mesmo bot antigo que foi escrito em C#, rodando no servidor do Discord da CSUL, mas eu mudei o código. Está melhor agora.

Como eu fiz

O bot está rodando agora nos servidores da Heroku, usando só recursos gratuitos. Tem alguns novos comandos na CLI da Heroku que podem causar problemas se você não prestar atenção. Eu vou listar aqui algumas coisas que eu quase esqueci enquanto lia as documentações, na primeira vez que tentei hospedar o bot.

→ Criar referência do Python

  • A Heroku não vai habilitar os buildpacks se eles não forem referenciados. Eu usei o heroku buildpacks:set heroku/python pra setar isso.
  • Isso pode ser configurado no comando heroku create, criando o aplicativo com o buildpack já inserido.

→ Configurar Procfile e os requirements

  • Esses dois arquivos precisam ser criados no mesmo diretório do arquivo .py. O Procfile não pode ter extensão, e vai receber os dynos web/worker pra conectar a aplicação com a Heroku.
  • Eu instalei o gunicorn pra usar os dynos, mas no final eu não precisei dele. Só passei o parâmetro python para rodá-los.

Procfile

  • O requirements.txt precisa ter todos os packages (comk as versões) que estão sendo usadas no app. Eu também esqueci de passar o parâmetro "discord==1.0.1" para chamar o pacote principal do Discord.
  • Na linha de comando, eu tive que mandar um heroku ps:scale web=1 worker=1 depois de editar o Procfile. Esse comando configura a quantidade de dynos que vão ser usados. Depois eu também precisei habilitar os dois dynos na página de resources da Heroku, dentro do Dashboard da aplicação.

Heroku Resources

→ Trocar branches e fazer o deploy

  • Sim, eu estava no branch master, que era o branch padrão da Heroku. Entretanto, eu precisei mudar para o main branch com o comando git checkout main. Depois de fazer isso, eu pude executar o git push.
  • O código que eu edito está no master branch (Github), eu só troco para o main toda vez que vou enviar o push para a Heroku. Da primeira vez que eu fiz o deploy, o bot estava dando ping a cada 30 segundos, e logando duas vezes num único push. O problema aqui era o uso desnecessário do gunicorn,que roda um novo servidor online, então eu precisei remover a linha "web: gunicorn main:app" no Procfile, alternando para python main.py que eu havia mencionado antes. Eu adicionei o dyno worker, editei algumas linhas no código principal e executei o git push. O bot está online, funcionando perfeitamente.

Online

Eu vou atualizar toda mudança ou problema da aplicação, esse readme só conta os métodos que eu usei pra resolver alguns problemas. Se tem algo que pode ser mudado ou resolvido de uma maneira melhor, eu posso editar esse texto a qualquer hora, para ser útil para outras pessoas.

Owner
Operaho
Deducing the future;
Operaho
Braje: a python based credit hacker tool. Hack unlimited RAJE LIKER app Credit

#ReCoded Evan Al Mahmud Irfan ✨ ථ BRAJE 1.0 AUTO LIKER, AUTO COMMENT AND AUTO FOLLOWER APP CREDIT HACKER TOOL About Braje: Braje is a python based cre

Evan Al Mahmud Irfan ථ 2 Dec 23, 2021
A telegram user and chat info extractor with pyrogram python module

Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.com/FayasNoushad/Telegram-Info/blob/main/LICENSE

Fayas Noushad 8 Dec 22, 2021
Ghostbuster - Eliminate dangling elastic IPs by performing analysis on your resources within all your AWS accounts

Table of Contents Table of Contents Ghostbuster The problem Project Features Ins

Assetnote 182 Dec 24, 2022
This is a okay that is okay that means none is okay

Owner: Masterolic 🇮🇳 CatUB A Powerful, Smart And Simple Userbot In Telethon. Credits This is A Remix Bot Of Many UserBot. DARKCOBRA FridayUserBot Ja

Masterolic 1 Nov 28, 2021
POC de uma AWS lambda que executa a consulta de preços de criptomoedas, e é implantada na AWS usando Github actions.

Cryptocurrency Prices Overview Instalação Repositório Configuração CI/CD Roadmap Testes Overview A ideia deste projeto é aplicar o conteúdo estudado s

Gustavo Santos 3 Aug 31, 2022
A ideia é fornecer uma base ampla de questões do ENEM como uma api REST

base10 "A ideia é fornecer uma base ampla de questões do ENEM como uma api REST" TODO Documentar a api com apifairy Criar testes Criar crawler para si

Wadson Garbes 4 Apr 24, 2022
TFT Bot that automatically surrenders and allows finishing TFT Passes easily.

Image Based TFT Bot TFT Bot that automatically surrenders and allows finishing TFT Passes easily. Please read full file! You can check new releases he

1 Feb 06, 2022
The accompanying code for the paper "GMAT: Global Memory Augmentation for Transformers" (Ankit Gupta and Jonathan Berant).

GMAT: Global Memory Augmentation for Transformers This repository contains the accompanying code for the paper: "GMAT: Global Memory Augmentation for

Ankit Gupta 7 Oct 21, 2021
A Discord bot that may save your day by predicting it.

Sage A Discord bot that may save your day by predicting it.

1 Nov 17, 2022
qualysclient - a python SDK for interacting with the Qualys API

qualysclient - a python SDK for interacting with the Qualys API

5 Oct 28, 2022
WordPress models and views for Django.

django-wordpress Models and views for reading a WordPress database. Compatible with WordPress version 3.5+. django-wordpress is a project of ISL and t

Jeremy Carbaugh 332 Dec 24, 2022
Flask-SQLAlchemy API for daisuki-web

💟 Anime Daisuki! API API de animes com cadastro de usuários. O usuário autenticado pode avaliar e favoritar animes, comentar episódios e verificar o

Paulo Thor 1 Nov 04, 2021
a harbinger of events or things.

Herald: Intrusion Detection System using IR and ML Herald - noun; a harbinger of events or things. Overview Herald is an intrusion detection system us

Muhammad Muzzammil 4 Jun 07, 2021
Compulsory join Telegram Bot

mussjoin About Compulsory join Telegram Bot this Telegram Bot Application can be added users to Telegram Channel or Group compulsorily. in addition wh

Hamed Mohammadvand 4 Dec 03, 2021
Create Basic ERC20 token with Solidity, Brownie and Python

Create Basic ERC20 token with Solidity, Brownie and Python Demo Check out Cornell Token on Rinnkeby network with Etherscan. Installation Install brown

Ethan Huang 2 Feb 16, 2022
Python wrapper for Coinex APIs

coinexpy - Python wrapper for Coinex APIs Through coinexpy you can simply buy or sell crypto in your Coinex account Features place limit order place m

Iman Mousaei 16 Jan 02, 2023
An API wrapper around Discord API written in Python

Diskord This library is a maintained fork of now archived library, discord.py. A modern and easy to use API wrapper around Discord API written in Pyth

Diskord 36 Aug 22, 2022
Discord-Lite - A light weight discord client written in Python, for developers, by developers.

Discord-Lite - A light weight discord client written in Python, for developers, by developers.

Sachit 142 Jan 07, 2023
Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy

Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy. Sell buyed token with custom gas fee, slippage, amount. And more.

Jesus Crypto 206 May 01, 2022
An Advanced Telegram Bot to Play Radio & Music in Voice Chat. This is Also The Source Code of The Bot Which is Being Used For Playing Radio in @AsmSafone Channel ❤️

Telegram Radio Player V3 An Advanced Telegram Bot to Play Nonstop Radio/Music/YouTube Live in Channel or Group Voice Chats. This is also the source co

SAF ONE 421 Jan 05, 2023