Skip to content

Instantly share code, notes, and snippets.

View meew0's full-sized avatar

meew0 meew0

View GitHub Profile
@meew0
meew0 / App.java
Created September 7, 2024 21:32
Standalone Java tool to generate 3 representative colours with good contrast from an image, to be used respectively as a background colour, an accent colour, and a muted foreground text colour. Uses https://github.com/trickl/palette/ as a base.
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package sa_image_palette;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@meew0
meew0 / apitosqa.md
Last active December 22, 2022 04:10
API ToS Q&A Summary

This is a summary of the Q&A regarding the new API ToS that took place in the #api channel on the Discord API server, starting around midnight UTC on Thursday, August 17, 2017.

All answers are from b1nzy unless marked otherwise. This is just a summary of my (meew0) own interpretation of the Q&A; obviously this shouldn't be interpreted as anything legally binding. If in doubt, ask the devs yourself or consult a lawyer. I'm not responsible if you get banned or sued because of this document. All subsequent usages of first-person pronouns refer to the people asking/answering the questions, respectively.

Q. How do we detect users deleting their accounts, if we have to delete their data within 7 days?
A. You will get an email by Discord if that happens. Make sure the account that registered the bot application has an email attached to it that you actually get messages with. This may change in the future but if it will, there will be plenty of time before the new mechanism goes into effect.

Q. **Do we need

@meew0
meew0 / guidelines.md
Last active September 23, 2023 18:09
Guidelines for lib inclusion on Discord API

There seems to be a lot of confusion regarding what exactly is required for a lib to be included in Discord API (i.e. get a channel, get listed in #info, and all the other good stuff). I've written all of the guidelines down as they were usually handled in the past and how they should be handled in the future, in my opinion. All of these are just guidelines - if you have a good enough reason to not meet a particular requirement, that's fine.

  • It should support the entire documented API featureset (minus voice). You can support undocumented stuff too if you want, but the entire documented featureset is a good minimum that can be expected of everyone who cares about their lib. (This seems more overwhelming than it really is.) Voice support is explicitly not required because there are many technical and non-technical reasons to not have it.
  • It should support advanced gateway features such as RESUMEs. There is a [rate limit on starting sessions](https://github.com/hammerandchisel/discord-api-doc
@meew0
meew0 / delegate_class.js
Last active October 1, 2016 17:00
Ruby's DelegateClass, implemented in ES6
// See http://ruby-doc.org/stdlib-2.3.1/libdoc/delegate/rdoc/Object.html for more information
// Some example classes...
class User {
constructor(username) {
this.username = username;
}
}
class Server {

Keybase proof

I hereby claim:

  • I am meew0 on github.
  • I am meew0 (https://keybase.io/meew0) on keybase.
  • I have a public key whose fingerprint is B777 2508 3140 303C CE9B EF3E 204E 4580 0AF8 8222

To claim this, I am signing this object:

@meew0
meew0 / ping.cr
Created September 4, 2016 20:09
discordcr ping bot
require "discordcr"
client = Discord::Client.new(token: "token", client_id: 12345_u64)
client.on_message do |payload|
client.create_message(payload.channel_id, "Pong!")
end
client.run
@meew0
meew0 / battle.rb
Created August 24, 2016 18:54
Elgyem .battle command
module Elgyem::Battle
extend ElgyemCommand
# OU, UU, RU, NU, PU, Ubers, BSS - or singles for all
# BSD, VGC, DOU, DUU, DUbers - or doubles for all
# BST, TOU - or triples for all
# BSS, BSD, BST - or battlespot for all
# OU, UU, RU, NU, PU, Ubers - or smogon for all
# Random
@meew0
meew0 / bulba-parser.rb
Created May 7, 2016 15:39
Ruby script to parse a dump of Bulbapedia's Pokémon pages into obtainability data
# This script parses a dump of Bulbapedia's Pokémon pages into a JSON file
# with details about what Pokémon are obtainable in respective regions
# (specifically, the latest series of games set in a specific region).
require 'nokogiri'
require 'json'
# An XML dump of all of Bulbapedia's Pokémon pages is required to exist at
# this path. It can be generated using this special page:
# http://bulbapedia.bulbagarden.net/wiki/Special:Export
  • Bot initializers now only use named parameters. This shouldn't be a hard change to adjust to, but everyone will have to do it. Here's some examples:
# Previously
bot = Discordrb::Bot.new '[email protected]', 'hunter2', true

# Now
bot = Discordrb::Bot.new email: '[email protected]', password: 'hunter2', log_mode: :debug
# Previously
module Elgyem::Agarify
extend ElgyemCommand
AGAR_ALPHABETS = [
# Exclude the boxed letters because they can look weird in Discord
# [9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414, 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423],
# [9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449],
[945, 1074, 162, 8706, 1108, 402, 103, 1085, 953, 1504, 1082, 8467, 1084, 951, 963, 961, 113, 1103, 1109, 1090, 965, 957, 969, 967, 1091, 122],
[65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, 65333, 65334, 65335, 65336, 65337, 65338],
[65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370],