mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 13:55:03 +00:00
Added Discord attachment link reaction, fixed emoji configuration and moved util functions
This commit is contained in:
parent
a4c4b17a14
commit
592d037148
173 changed files with 1540 additions and 1170 deletions
|
@ -2,8 +2,8 @@ import { Snowflake, TextChannel } from "discord.js";
|
|||
import { guildPluginMessageCommand } from "knub";
|
||||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { UnknownUser, resolveUser } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { setCounterValue } from "../functions/setCounterValue";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
|
@ -45,22 +45,22 @@ export const SetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
sendErrorMessage(pluginData, message.channel, `Unknown counter: ${args.counterName}`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `Unknown counter: ${args.counterName}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (counter.can_edit === false) {
|
||||
sendErrorMessage(pluginData, message.channel, `Missing permissions to edit this counter's value`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `Missing permissions to edit this counter's value`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.channel && !counter.per_channel) {
|
||||
sendErrorMessage(pluginData, message.channel, `This counter is not per-channel`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `This counter is not per-channel`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.user && !counter.per_user) {
|
||||
sendErrorMessage(pluginData, message.channel, `This counter is not per-user`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `This counter is not per-user`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,13 +69,13 @@ export const SetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which channel's counter value would you like to change?`);
|
||||
const reply = await waitForReply(pluginData.client, message.channel, message.author.id);
|
||||
if (!reply || !reply.content) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
|
||||
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,13 +87,13 @@ export const SetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which user's counter value would you like to change?`);
|
||||
const reply = await waitForReply(pluginData.client, message.channel, message.author.id);
|
||||
if (!reply || !reply.content) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
const potentialUser = await resolveUser(pluginData.client, reply.content);
|
||||
if (!potentialUser || potentialUser instanceof UnknownUser) {
|
||||
sendErrorMessage(pluginData, message.channel, "Unknown user, cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Unknown user, cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ export const SetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send("What would you like to set the counter's value to?");
|
||||
const reply = await waitForReply(pluginData.client, message.channel, message.author.id);
|
||||
if (!reply || !reply.content) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
const potentialValue = parseInt(reply.content, 10);
|
||||
if (Number.isNaN(potentialValue)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Not a number, cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Not a number, cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ export const SetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
}
|
||||
|
||||
if (value < 0) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cannot set counter value below 0");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Cannot set counter value below 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue