mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +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 { changeCounterValue } from "../functions/changeCounterValue";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
|
@ -45,22 +45,22 @@ export const AddCounterCmd = 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 AddCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which channel's counter value would you like to add 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 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 AddCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which user's counter value would you like to add 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 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 AddCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send("How much would you like to add to the counter's value?");
|
||||
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 potentialAmount = parseInt(reply.content, 10);
|
||||
if (!potentialAmount) {
|
||||
sendErrorMessage(pluginData, message.channel, "Not a number, cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Not a number, cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { guildPluginMessageCommand } from "knub";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { trimMultilineString, ucfirst } from "../../../utils";
|
||||
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
export const CountersListCmd = guildPluginMessageCommand<CountersPluginType>()({
|
||||
|
@ -15,7 +15,7 @@ export const CountersListCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
|
||||
const countersToShow = Array.from(Object.values(config.counters)).filter((c) => c.can_view !== false);
|
||||
if (!countersToShow.length) {
|
||||
sendErrorMessage(pluginData, message.channel, "No counters are configured for this server");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "No counters are configured for this server");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { guildPluginMessageCommand } from "knub";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { confirm, noop, trimMultilineString } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { resetAllCounterValues } from "../functions/resetAllCounterValues";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
|
@ -18,17 +18,19 @@ export const ResetAllCounterValuesCmd = guildPluginMessageCommand<CountersPlugin
|
|||
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_reset_all === false) {
|
||||
sendErrorMessage(pluginData, message.channel, `Missing permissions to reset all of this counter's values`);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(message, `Missing permissions to reset all of this counter's values`);
|
||||
return;
|
||||
}
|
||||
|
||||
const counterName = counter.name || args.counterName;
|
||||
const confirmed = await confirm(message.channel, message.author.id, {
|
||||
const confirmed = await confirm(message, message.author.id, {
|
||||
content: trimMultilineString(`
|
||||
Do you want to reset **ALL** values for counter **${counterName}**?
|
||||
This will reset the counter for **all** users and channels.
|
||||
|
@ -36,7 +38,7 @@ export const ResetAllCounterValuesCmd = guildPluginMessageCommand<CountersPlugin
|
|||
`),
|
||||
});
|
||||
if (!confirmed) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cancelled");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,7 +49,9 @@ export const ResetAllCounterValuesCmd = guildPluginMessageCommand<CountersPlugin
|
|||
await resetAllCounterValues(pluginData, args.counterName);
|
||||
|
||||
loadingMessage?.delete().catch(noop);
|
||||
sendSuccessMessage(pluginData, message.channel, `All counter values for **${counterName}** have been reset`);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(message, `All counter values for **${counterName}** have been reset`);
|
||||
|
||||
pluginData.getKnubInstance().reloadGuild(pluginData.guild.id);
|
||||
},
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
@ -40,22 +40,22 @@ export const ResetCounterCmd = 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 reset this counter's value`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `Missing permissions to reset 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;
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,13 @@ export const ResetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which channel's counter value would you like to reset?`);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,13 @@ export const ResetCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which user's counter value would you like to reset?`);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ import { Snowflake } from "discord.js";
|
|||
import { guildPluginMessageCommand } from "knub";
|
||||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
export const ViewCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
||||
|
@ -39,22 +39,22 @@ export const ViewCounterCmd = 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_view === false) {
|
||||
sendErrorMessage(pluginData, message.channel, `Missing permissions to view this counter's value`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, `Missing permissions to view 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;
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,13 @@ export const ViewCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which channel's counter value would you like to view?`);
|
||||
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?.isTextBased()) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,13 +81,13 @@ export const ViewCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
|||
message.channel.send(`Which user's counter value would you like to view?`);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue