Skip to content

Instantly share code, notes, and snippets.

View krisppurg's full-sized avatar
🎯

krisppurg

🎯
  • mystery
  • 00:08 (UTC +01:00)
View GitHub Profile
@krisppurg
krisppurg / voice.nim
Created March 5, 2023 12:31
voice in my test bot
## voice in my test bot
## expect some random stuff with some lazy code, im not bothered about it as long as it works lol
## note: the code is filtered with only voice related stuff, although there are some parts that are irrelevent or useless
## just ignore them.
when defined(dimscordStable):
import dimscord
else:
import ../../dimscord/dimscord
@krisppurg
krisppurg / slash_commands.nim
Created May 30, 2021 21:39
Dimscord Nimconf 2021: My implementation of slash commands in dimscord
proc interactionCreate(s: Shard, i: Interaction) {.event(discord).} =
await discord.api.createInteractionResponse(i.id, i.token,
InteractionResponse(
kind: irtDeferredChannelMessageWithSource
)
)
let data = get i.data
case data.name:
of "beep", "beepo":
var content = data.options["message"].str.get
@krisppurg
krisppurg / cachable.nim
Created May 30, 2021 21:22
cachable.nim updated nimconf 2021 code
import dimscord, asyncdispatch, strutils, options, tables
let discord = newDiscordClient("")
proc getGuild(s: Shard, guild_id: string): Future[Guild] {.async.} =
if guild_id in s.cache.guilds:
return s.cache.guilds[guild_id]
result = await discord.api.getGuild(guild_id)
proc getGuildChannel(s: Shard, chan_id: string): Future[GuildChannel] {.async.} =
@krisppurg
krisppurg / jesus-canvas.js
Last active July 8, 2018 23:14
Add an image to a Jesus meme using canvas-constructor
const { Canvas } = require("canvas-constructor"); // Import the Canvas thing from the 'canvas-constructor'.
const snekfetch = require("snekfetch") // Create a variable called 'snekfetch' that imports the snekfetch package aka the http request to get the image buffer.
function jesus(glob) {
// Get the jesus image
return snekfetch.get("https://cdn.discordapp.com/attachments/411126540131106816/465197193163440128/jesus.jpeg").then(res => {
const image = new Canvas(900, 756)
.addImage(res.body, 0, 0, 900, 756) // Adds the jesus image with x, y, width height
.addImage(glob, 420, 410, 500, 340) // adds the glob image with x, y, width height