Vote Server Reference
Creating the webhook server
Example:
from discord.ext import commands
from toppy import server
bot = commands.Bot("!")
bot.webhook_server = bot.loop.run_until_complete(server.create_server(
bot,
"0.0.0.0",
8080,
"/vote",
"super cool auth secret"
))
bot.run("...")
bot.webhook_server.cancel() # closes the server. Not really needed when the program is quitting, but oh well.
The create server function
- toppy.create_server(*args, **kwargs) Task
Alias for :function:`start_server`, but imitating the old <1.4.2 behaviour
Vote types
The following vote types may be passed to the event on_vote:
- class toppy.ServerVote(data: dict, *, state=None)
Represents a vote for a server listing
- property guild: Union[Guild, Object]
Returns the guild that was voted on.
Warning
similar to
SharedVote.user, this function will returndiscord.Objectif the internal cache lookup returns nothing.- Returns
- property user
Returns the user who voted.
Warning
If you don’t have the member cache, or members intent, then this function will always return
discord.Object, as that is the default when the get_user call fails.- Returns
- class toppy.BotVote(data: dict, *, state=None)
Represents a vote for a Bot listing
- Attributes:
- property bot: Union[User, Object]
The resolved bot user for this vote. This is, hopefully, always your current bot.
Warning
If the internal lookup fails, this returns a
discord.Objectby default.- Returns
- property user
Returns the user who voted.
Warning
If you don’t have the member cache, or members intent, then this function will always return
discord.Object, as that is the default when the get_user call fails.- Returns
Vote Event Reference
- on_vote(vote: Union[BotVote, ServerVote]):
Dispatched whenever there is a vote. Be sure to check the vote type and class.