From 2a68522abd0cb07cdce56d304dd345e7b9714538 Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Tue, 27 Sep 2022 11:37:56 -0400 Subject: [PATCH] fix deletereaction, started setting up service files --- README.md | 2 +- config.example.ts | 2 +- src/functions/pollReactions.ts | 2 +- sweeper.rc | 20 ++++++++++++++++++++ sweeper.service | 14 ++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 sweeper.rc create mode 100644 sweeper.service diff --git a/README.md b/README.md index 18d4e94..c5e0abe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sweeper Bot | V0.4.0 - 2022/09/09 +# Sweeper Bot | V0.4.4 - 2022/09/27 [![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-orange.svg)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=bugs)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=SweeperBot) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=SweeperBot&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=SweeperBot) diff --git a/config.example.ts b/config.example.ts index e61a79f..bad0538 100644 --- a/config.example.ts +++ b/config.example.ts @@ -1,6 +1,6 @@ export const config = { 'name': 'Sweeper Bot', // Name of the bot - 'version': '0.4.2', // Version of the bot + 'version': '0.4.4', // Version of the bot 'token': 'the_bot_token', // Discord API Token for this bot 'localtoken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" 'prefix': 's!', // Prefix for all commands diff --git a/src/functions/pollReactions.ts b/src/functions/pollReactions.ts index 65bc66a..fb28789 100644 --- a/src/functions/pollReactions.ts +++ b/src/functions/pollReactions.ts @@ -29,7 +29,7 @@ export const pollReactions = async (bot: Bot, message: Message, update = false) if (reaction.emoji.name) { // Make emoji name that matches our allEmojis array format const emojiName = reaction.emoji.id ? `:${reaction.emoji.name}:${reaction.emoji.id}` : reaction.emoji.name; - await bot.helpers.deleteReaction(message.channelId, message.id, emojiName).catch((e: Error) => utils.commonLoggers.reactionDeleteError('pollReactions.ts:32', message, e, emojiName)); + await bot.helpers.deleteReactionsEmoji(message.channelId, message.id, emojiName).catch((e: Error) => utils.commonLoggers.reactionDeleteError('pollReactions.ts:32', message, e, emojiName)); } } } diff --git a/sweeper.rc b/sweeper.rc new file mode 100644 index 0000000..6903e3e --- /dev/null +++ b/sweeper.rc @@ -0,0 +1,20 @@ +#!/bin/sh + +# PROVIDE: sweeper + +. /etc/rc.subr + +name="sweeper" +rcvar="sweeper_enable" +pidfile="/var/dbots/SweeperBot/sweeper.pid" + +sweeper_root="/var/dbots/SweeperBot" +sweeper_write="./logs/" +sweeper_log="/var/log/sweeper.log" + +sweeper_chdir="${sweeper_root}" +command="/usr/sbin/daemon" +command_args="-f -R 5 -P ${pidfile} -o ${sweeper_log} /usr/local/bin/deno run --allow-write=${sweeper_write} --allow-net ${sweeper_root}/mod.ts" + +load_rc_config sweeper +run_rc_command "$1" diff --git a/sweeper.service b/sweeper.service new file mode 100644 index 0000000..c6b878f --- /dev/null +++ b/sweeper.service @@ -0,0 +1,14 @@ +[Unit] +Description=Sweeper Bot Discord Bot +Documentation=https://github.com/Burn-E99/SweeperBot +After=network.target + +[Service] +Type=simple +PIDFile=/run/deno.pid +ExecStart=/root/.deno/bin/deno run --allow-write=./logs/ --allow-net .\mod.ts +RestartSec=60 +Restart=on-failure + +[Install] +WantedBy=multi-user.target