From 21385804af3cc779fab4ed538b2f0c7eb81bc3a5 Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 16 Sep 2020 12:47:13 -0400 Subject: [PATCH] more fixes --- README.md | 2 +- docs/content/advanced/dynamiccommands.md | 6 +++--- docs/content/advanced/subcommands.md | 10 +++++----- docs/content/gettingstarted.md | 2 +- docs/content/stepbystep/createcommand.md | 4 ++-- mod.ts | 1 + src/controllers/cache.ts | 10 ++++++++++ 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c89e978f1..02cf0cf4e 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Client({ }, messageCreate: (message) => { if (message.content === "!ping") { - sendMessage(message.channel, "Pong"); + sendMessage(message.channelID, "Pong"); } } } diff --git a/docs/content/advanced/dynamiccommands.md b/docs/content/advanced/dynamiccommands.md index ff98a2d60..313ee0719 100644 --- a/docs/content/advanced/dynamiccommands.md +++ b/docs/content/advanced/dynamiccommands.md @@ -101,7 +101,7 @@ nekosEndpoints.forEach((endpoint) => { execute: async function (message) { const url = `https://nekos.life/api/v2${endpoint.path}`; const result = await fetch(url).then((res) => res.json()); - sendMessage(message.channel, result?.url); + sendMessage(message.channelID, result?.url); }, }); }); @@ -124,7 +124,7 @@ nekosEndpoints.forEach((endpoint) => { execute: async function (message) { const url = `https://nekos.life/api/v2${endpoint.path}`; const result = await fetch(url).then((res) => res.json()); - sendMessage(message.channel, result?.url); + sendMessage(message.channelID, result?.url); }, }); }); @@ -142,7 +142,7 @@ botCache.commands.set(endpoint.name, { execute: async function (message) { const url = `https://nekos.life/api/v2${endpoint.path}`; const result = await fetch(url).then((res) => res.json()); - sendMessage(message.channel, result?.url); + sendMessage(message.channelID, result?.url); }, }); ``` diff --git a/docs/content/advanced/subcommands.md b/docs/content/advanced/subcommands.md index d7eb3ed44..dbabef191 100644 --- a/docs/content/advanced/subcommands.md +++ b/docs/content/advanced/subcommands.md @@ -40,7 +40,7 @@ botCache.commands.set("prefix", { `) .setTimestamp(); - sendEmbed(message.channel, embed); + sendEmbed(message.channelID, embed); }, }); @@ -74,7 +74,7 @@ createSubcommand("prefix", { `) .setTimestamp(); - sendEmbed(message.channel, embed); + sendEmbed(message.channelID, embed); }, }); ``` @@ -102,7 +102,7 @@ botCache.commands.set("prefix", { `) .setTimestamp(); - sendEmbed(message.channel, embed); + sendEmbed(message.channelID, embed); }, }); ``` @@ -140,7 +140,7 @@ createSubcommand("prefix", { `) .setTimestamp(); - sendEmbed(message.channel, embed); + sendEmbed(message.channelID, embed); }, }); ``` @@ -221,4 +221,4 @@ createSubcommand("settings-feedback", { --- -**THE POWER AND MAGIC OF DISCORDENO AT YOUR FINGERTIPS!** +**THE POWER AND MAGIC OF DISCORDENO AT YOUR FINGERTIPS!** diff --git a/docs/content/gettingstarted.md b/docs/content/gettingstarted.md index 23dfdeac4..0363c28f4 100644 --- a/docs/content/gettingstarted.md +++ b/docs/content/gettingstarted.md @@ -60,7 +60,7 @@ Client({ }, messageCreate: (message) => { if (message.content === "!ping") { - sendMessage(message.channel, "Pong"); + sendMessage(message.channelID, "Pong"); } } } diff --git a/docs/content/stepbystep/createcommand.md b/docs/content/stepbystep/createcommand.md index 5d10d8479..0cf7f791c 100644 --- a/docs/content/stepbystep/createcommand.md +++ b/docs/content/stepbystep/createcommand.md @@ -20,7 +20,7 @@ botCache.commands.set("invite", { execute: function (message) { // Replace the permission number at the end to request the permissions you wish to request. By default, this will request Admin perms. sendMessage( - message.channel, + message.channelID, `https://discordapp.com/oauth2/authorize?client_id=${botID}&scope=bot&permissions=8`, ); }, @@ -586,7 +586,7 @@ funCommandData.forEach((data) => { ) .setImage(chooseRandom(data.gifs)); - return sendEmbed(message.channel, embed); + return sendEmbed(message.channelID, embed); }, }); diff --git a/mod.ts b/mod.ts index 7aeed6ffc..2440f74c2 100644 --- a/mod.ts +++ b/mod.ts @@ -2,6 +2,7 @@ import createClient from "./src/module/client.ts"; export * from "./src/controllers/mod.ts"; export * from "./src/controllers/bans.ts"; +export * from "./src/controllers/cache.ts"; export * from "./src/controllers/channels.ts"; export * from "./src/controllers/guilds.ts"; export * from "./src/controllers/members.ts"; diff --git a/src/controllers/cache.ts b/src/controllers/cache.ts index 57fdbc1d4..395ecfd2f 100644 --- a/src/controllers/cache.ts +++ b/src/controllers/cache.ts @@ -80,15 +80,25 @@ function forEach( } export let cacheHandlers = { + /** Deletes all items from the cache */ + clear: async function (table: TableName) { + return cache[table].clear(); + }, + /** Deletes 1 item from cache using the key */ delete: async function (table: TableName, key: string) { return cache[table].delete(key); }, + /** Check if something exists in cache with a key */ has: async function (table: TableName, key: string) { return cache[table].has(key); }, + // Done differently to have overloads + /** Add a key value pair to the cache */ set, + /** Get the value from the cache using its key */ get, + /** Run a function on all items in this cache */ forEach, };