3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Update to Knub30.0.0-beta.37 and Eris 0.15, first pass

This commit is contained in:
Dragory 2021-05-23 14:35:16 +03:00
parent 84da543205
commit f6be4f4af6
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
133 changed files with 6507 additions and 380 deletions

View file

@ -106,7 +106,8 @@ const configPreprocessor: ConfigPreprocessorFn<CountersPluginType> = options =>
* A single trigger can only trigger once per user/channel/in general, depending on how specific the counter is (e.g. a per-user trigger can only trigger once per user).
* After being triggered, a trigger is "reset" if the counter value no longer matches the trigger (e.g. drops to 100 or below in the above example). After this, that trigger can be triggered again.
*/
export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counters", {
export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
name: "counters",
showInDocs: true,
info: {
prettyName: "Counters",
@ -145,7 +146,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counter
ResetAllCounterValuesCmd,
],
async onLoad(pluginData) {
async afterLoad(pluginData) {
pluginData.state.counters = new GuildCounters(pluginData.guild.id);
pluginData.state.events = new EventEmitter();
pluginData.state.counterTriggersByCounterId = new Map();
@ -207,7 +208,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counter
}
},
onUnload(pluginData) {
beforeUnload(pluginData) {
for (const interval of pluginData.state.decayTimers) {
clearInterval(interval);
}

View file

@ -1,4 +1,4 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
@ -7,7 +7,7 @@ import { TextChannel, User } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue";
export const AddCounterCmd = guildCommand<CountersPluginType>()({
export const AddCounterCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters add", "counter add", "addcounter"],
permission: "can_edit",
@ -41,7 +41,7 @@ export const AddCounterCmd = guildCommand<CountersPluginType>()({
],
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const counter = config.counters[args.counterName];
const counterId = pluginData.state.counterIds[args.counterName];
if (!counter || !counterId) {

View file

@ -1,17 +1,17 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";
import { trimMultilineString, ucfirst } from "../../../utils";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
export const CountersListCmd = guildCommand<CountersPluginType>()({
export const CountersListCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters list", "counter list", "counters"],
permission: "can_view",
signature: {},
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const countersToShow = Array.from(Object.values(config.counters)).filter(c => c.can_view !== false);
if (!countersToShow.length) {

View file

@ -1,4 +1,4 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
@ -10,7 +10,7 @@ import { setCounterValue } from "../functions/setCounterValue";
import { resetAllCounterValues } from "../functions/resetAllCounterValues";
import { counterIdLock } from "../../../utils/lockNameHelpers";
export const ResetAllCounterValuesCmd = guildCommand<CountersPluginType>()({
export const ResetAllCounterValuesCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters reset_all"],
permission: "can_reset_all",
@ -19,7 +19,7 @@ export const ResetAllCounterValuesCmd = guildCommand<CountersPluginType>()({
},
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const counter = config.counters[args.counterName];
const counterId = pluginData.state.counterIds[args.counterName];
if (!counter || !counterId) {

View file

@ -1,4 +1,4 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
@ -7,7 +7,7 @@ import { TextChannel } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
import { setCounterValue } from "../functions/setCounterValue";
export const ResetCounterCmd = guildCommand<CountersPluginType>()({
export const ResetCounterCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters reset", "counter reset", "resetcounter"],
permission: "can_edit",
@ -36,7 +36,7 @@ export const ResetCounterCmd = guildCommand<CountersPluginType>()({
],
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const counter = config.counters[args.counterName];
const counterId = pluginData.state.counterIds[args.counterName];
if (!counter || !counterId) {

View file

@ -1,4 +1,4 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
@ -8,7 +8,7 @@ import { resolveUser, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue";
import { setCounterValue } from "../functions/setCounterValue";
export const SetCounterCmd = guildCommand<CountersPluginType>()({
export const SetCounterCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters set", "counter set", "setcounter"],
permission: "can_edit",
@ -42,7 +42,7 @@ export const SetCounterCmd = guildCommand<CountersPluginType>()({
],
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const counter = config.counters[args.counterName];
const counterId = pluginData.state.counterIds[args.counterName];
if (!counter || !counterId) {

View file

@ -1,4 +1,4 @@
import { guildCommand } from "knub";
import { typedGuildCommand } from "knub";
import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
@ -6,7 +6,7 @@ import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel, User } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
export const ViewCounterCmd = guildCommand<CountersPluginType>()({
export const ViewCounterCmd = typedGuildCommand<CountersPluginType>()({
trigger: ["counters view", "counter view", "viewcounter", "counter"],
permission: "can_view",
@ -35,7 +35,7 @@ export const ViewCounterCmd = guildCommand<CountersPluginType>()({
],
async run({ pluginData, message, args }) {
const config = pluginData.config.getForMessage(message);
const config = await pluginData.config.getForMessage(message);
const counter = config.counters[args.counterName];
const counterId = pluginData.state.counterIds[args.counterName];
if (!counter || !counterId) {