API reference
Server events and polls
Create Discord server events and native polls from a command.
A server event is the event Discord shows at the top of the channel list, with a date and an "Interested" button. A poll is Discord's own vote message.
Write await in front of every function on this page.
The bot needs the Create Events or Manage Events permission for events, and Send Messages for polls.
create_event#
Creates a server event. Returns the event.
await create_event(
name,
start_time,
type="external",
end_time=None,
location=None,
channel=None,
description=None,
image=None,
)| Argument | What it does |
|---|---|
name | The event name. |
start_time | When it starts, like "saturday 8pm". Must be in the future. |
type | external, voice or stage. |
end_time | When it ends. Must be after the start. |
location | Where it is, as text. Only for external. |
channel | The voice or stage channel. Only for voice and stage. |
description | More details about the event. |
image | A cover image. |
What each type needs:
type | Needs |
|---|---|
external | location and end_time |
voice | channel |
stage | channel |
Example: a movie night in a voice channel
ev = await create_event(
"Movie night",
"friday 9pm",
type="voice",
channel="Cinema",
description="Bring snacks.",
)
set_content(f"Event made: **{ev.name}**")Example: an event outside Discord
await create_event(
"Meetup",
"next saturday 2pm",
location="Central Park",
end_time="next saturday 5pm",
)edit_event#
Changes an event. Pass only what you want to change.
await edit_event(
event,
name=None,
start_time=None,
end_time=None,
location=None,
channel=None,
description=None,
)event is the event, or its ID. Fails with "Nothing to edit" when you pass no changes.
await edit_event(event_id, start_time="friday 10pm")cancel_event#
Deletes an event.
await cancel_event(event)start_event#
Marks an event as started.
await start_event(event)end_event#
Marks an event as ended.
await end_event(event)Tip
Save the event ID with update_server_var("movie_event", ev.id). Then other commands can edit, start or end it.
create_poll#
Posts a Discord poll. Returns the poll message.
await create_poll(question, answers, channel=None, duration=24, multiselect=False)| Argument | What it does |
|---|---|
question | The question. Up to 300 characters. |
answers | A list of 2 to 10 answers. Each up to 55 characters. Extra answers are dropped. |
channel | Where to post. Defaults to the current channel. |
duration | How long the poll stays open, in hours. 1 to 768 (32 days). |
multiselect | True lets people pick more than one answer. |
await create_poll(
"Which game tonight?",
["Minecraft", "Among Us", "Valorant"],
duration=4,
)
set_content("Poll is up!")To open a poll later, use schedule("create_poll", ...). See Scheduling. For a full walk-through, see the Poll guide.