Skip to content

Instantly share code, notes, and snippets.

@AkshuAgarwal
AkshuAgarwal / interactions.md
Last active April 12, 2024 18:32
A Basic guide about Discord Interactions and how to use them in discord.py

Interactions

Before Starting, note that this is a Walkthrough of How to respond and not How to make. Responding includes understanding of interactions and responding to User, whereas making includes Components which are made using Views and Component Classes.

If you want to know about how to make them, there's not any guide in particular yet (or atleast I'm not aware of any) but there is always the Documentation and some great Examples! If there will be any guide for this in future, I'll link that here.



Index

@AkshuAgarwal
AkshuAgarwal / switch_case.py
Created July 16, 2021 10:06
A simple Switch-case class for python
class Switch:
def __init__(self, input_message: str, *, response: dict):
self._input_msg: str = input_message
if any(isinstance(i, str) for i in response.keys()):
raise ValueError('response keys can only be of str type')
self._response = response
self._input = None
@AkshuAgarwal
AkshuAgarwal / webhook.py
Last active April 13, 2024 17:02
Send Message using Discord Webhooks by making request or using discord.py
"""Making a post request to Webhook, without using discord.py"""
import aiohttp
webhook_url = "your_webhook's_url" # URL of the Webhook (make sure NOT TO SHARE IT WITH ANYONE.)
# JSON data to send to the Webhook.
# You can find the data payload at https://discord.com/developers/docs/resources/webhook#execute-webhook
data = {
'content': 'Hello, world!',