Skip to content

Latest commit

 

History

History
63 lines (38 loc) · 2.66 KB

README.md

File metadata and controls

63 lines (38 loc) · 2.66 KB

DiscordBots Webhook Py Handler

Hello! This is an example to help people use Discord Bots webhooks to handle upvotes/and reward them based on if they upvoted.

This is just an example to use the webhooks. You may modify if you would like, and fork if you want to contribute.

Everything should work but I'm still adding things, making it formal.

Made by NekoTony#0047

Requirements: Flask 0.12.2 Discord.py 1.0.0a Python3

Installation

Flask: I recommended checking out these urls:

Official Flask Docs How to Configure NGINX for a Flask Web Application

Discord.py Rewrite:

python3 -m pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py\[voice\]

Current don't have an async example, Fork if you would like to add one.

Python3 Download Python

How to Use

First, download the files in the config. Once you have installed anything, add vote.py to wherever you store your modules and flask.py wherever you store your python files.

Configuration:

To config the webhooks to your settings, you'll need to edit config.json. Please ignore the preset data there.

botid auth post voteurl upvotepath reset
Your discord bot ID Your Authorization keyword that you had set thru bot/edit on the official site. Where you want the Dbots to send upvotes. Ex: http://myurl/post/too Link to where people can vote for your bot Where upvotes.json is located Whether or not you want to store past day upvotes. 0 is default, meaning you would like to store past days. Otherwise, if you want to store only the current day upvotes then set it to 1. Set it to 1 if you want to save space.

Also, make sure your config path is correct as well. You can set that self.config in vote.py.

Once you config it, start the flask server and the upvotes.json will update when an someone has upvoted your bot on the site.

Storage:

All upvotes are stored in a .json file and can be easily accessed with simple json knowledge or by using the functions provided. Here's an example to access them:

import json
from datetime import datetime

today = datetime.today().strftime('%Y-%m-%d') #Get todays date 
upvotes = get_userids() #Get the entire json file.
today_vote = upvotes[today] #Current Data Vote

#You can also get today's vote by doing this
today_vote  = get_userids(today)

All dates are formatted like this: 2018-03-29

It should be easy to use to access.