Skip to content

Instantly share code, notes, and snippets.

View VelvetToroyashi's full-sized avatar
🚩
Finding myself ever whelmed day by day.

Velvet VelvetToroyashi

🚩
Finding myself ever whelmed day by day.
View GitHub Profile
@VelvetToroyashi
VelvetToroyashi / Benchmark.cs
Created August 28, 2024 06:44
Inserting into a dictionary of lists
public class DictionaryTests
{
private record Data(string Name, string Value);
private readonly Data[] _data =
[
new("some_thing", "Value"), new("array1", "value 1"), new("array1", "value 2"), new("array1", "value 3"), new("array1", "value 4"),
new("array2", "value 1"), new("array2", "value 2"), new("array2", "value 3"), new("array2", "value 4"), new("array2", "value 5"),
new("random_1253", "value 1"), new("random_4307", "value 2"), new("random_123", "value 3"), new("random_thing", "value 4"), new("random_3r38", "value 5"),
];
OTAyMjkzMzQ2MTI1NDkyMzQ0.GzZV6i.NiC4QWqVVti2YtHyDq0agJuYVYZotVeZQFcQDc
@VelvetToroyashi
VelvetToroyashi / BannerCommands.cs
Created May 20, 2022 02:30
Command that vaguely replicates Discord's automated banner color picking. HSV is 2 off, and I'm not sure how to fix it.
using System;
using System.ComponentModel;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using OneOf;
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;

Silk! V3 Changelog:

This document is a summarization of changes that occurred during the V3 rewrite of Silk!.

A LOT has changed in V3; this serves as an overview of the changes, and how they may impact you.

Frontend:

Commands:

Commands that were executable as a group are no longer existent. Sorry :(

@VelvetToroyashi
VelvetToroyashi / select.ts
Created May 27, 2021 01:20 — forked from invertedcaramel/select.ts
Discord Bot UI Kit Select
enum ComponentType {
ACTION_ROW,
BUTTON,
SELECT
}
interface Snowflake extends String {}
interface Emoji {
id: Snowflake;
@VelvetToroyashi
VelvetToroyashi / RoleMenu_Interactive.cs
Last active May 27, 2021 03:41
An implementation of an interactive, button-based role menu.
public async Task CreateInteractive(CommandContext ctx)
{
string buttonIdPrefix = $"{ctx.Message.Id}|{ctx.User.Id}|rolemenu|";
InteractivityExtension input = ctx.Client.GetInteractivity();
InteractivityResult<DiscordMessage> messageInput;
InteractivityResult<ComponentInteractionCreateEventArgs> buttonInput;
DiscordFollowupMessageBuilder followupMessageBuilder = new();
DiscordMessage currentMessage;
DiscordMessage roleMenuDiscordMessage = null!;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.CommandsNext.Converters;
using DSharpPlus.Entities;
namespace DSharpPlus.Test
/// <summary>
/// A dictionary that hides the underlying type that it holds, and casts on-demand.
/// <remarks> Type and cast safety is not guaranteed by this class. Caution should be taken to ensure that values can be casted, by operator or inheritence.</remarks>
/// </summary>
/// <exception cref="System.InvalidCastException"><typeparamref name="TValueFrom"/> is not castable to <typeparamref name="TValueTo"/>.</exception>
/// <typeparam name="TKey">The type to store as the key.</typeparam>
/// <typeparam name="TValueFrom">The underlying type to store.</typeparam>
/// <typeparam name="TValueTo">The type to cast elements to.</typeparam>
public sealed class CastingDictionary<TKey, TValueFrom, TValueTo> : IDictionary<TKey, TValueTo> where TKey : notnull
{
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using DSharpPlus.Interactivity;
using Silk.Core.Constants;
namespace Silk.Core.Commands.Tests.RoleMenu
{
/// <summary>
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using SilkBot.Database.Models;