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.VoteType
TEST
UPVOTE
class toppy.ServerVote(data: dict, *, state=None)

Represents a vote for a server listing

Attributes:

type: VoteType

query: str

property guild: Union[Guild, Object]

Returns the guild that was voted on.

Warning

similar to SharedVote.user, this function will return discord.Object if the internal cache lookup returns nothing.

Returns

discord.Guild or discord.Object.

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

discord.User or discord.Object.

class toppy.BotVote(data: dict, *, state=None)

Represents a vote for a Bot listing

Attributes:
type: VoteType

The type of vote (test or upvote)

is_weekend: bool

Represents if votes are worth double

isWeekend: bool

alias for BotVote.is_weekend

query: str

The querystring while voting

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.Object by default.

Returns

discord.User or discord.Object.

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

discord.User or discord.Object.

Vote Event Reference

on_vote(vote: Union[BotVote, ServerVote]):

Dispatched whenever there is a vote. Be sure to check the vote type and class.