Skip to content

Make bot suitable for multiple servers#67

Open
TrojanerHD wants to merge 44 commits into
mainfrom
database
Open

Make bot suitable for multiple servers#67
TrojanerHD wants to merge 44 commits into
mainfrom
database

Conversation

@TrojanerHD

@TrojanerHD TrojanerHD commented Jan 14, 2023

Copy link
Copy Markdown
Owner
  • Change to database for storing guild-related settings
  • Make bot settings customizable via commands
  • Fix new bugs due to implemented features
    • Wrong behavior / missing functionality when joining a new server
  • Make sure the command permissions can be updated (send authorize URL to executor of /permit command if required)
  • Test if everything works as intended

@TrojanerHD

TrojanerHD commented Mar 5, 2023

Copy link
Copy Markdown
Owner Author

Currently known bug: The bot has to be fully restarted in order to use the live and roles channel in a server it has been added during runtime

Comment thread src/ReactionHandler.ts Outdated
Comment thread src/messages/MessageHandler.ts Outdated
Comment thread README.md Outdated
Comment thread src/messages/PermitCommand.ts
Comment thread src/messages/RolesCommand.ts Outdated
Comment thread src/messages/RolesCommand.ts
Comment thread src/roles/RoleChannelManager.ts Outdated
Comment thread src/settings/GuildSettings.ts Outdated
Comment thread src/twitch/LiveChannel.ts Outdated
Comment thread src/twitch/TwitchHelper.ts Outdated
@TrojanerHD TrojanerHD marked this pull request as ready for review March 12, 2023 22:10
@TrojanerHD TrojanerHD mentioned this pull request Mar 18, 2023
Comment thread src/messages/PermitCommand.ts Outdated
Comment thread src/messages/PermitCommand.ts Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread src/ReactionHandler.ts
Comment thread src/messages/MessageHandler.ts Outdated
Comment thread src/messages/permissions/Authentication.ts
Comment thread src/messages/permissions/Authentication.ts Outdated
Comment thread src/messages/permissions/Authentication.ts Outdated
Comment thread src/messages/permissions/CommandPermissions.ts Outdated
Comment thread src/messages/permissions/CommandPermissions.ts Outdated
Comment thread src/messages/permissions/CommandPermissions.ts Outdated
Comment thread README.md
Comment on lines 15 to 16
## Deployment and contribution
### Requirements

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docker deployment explanation

@TrojanerHD

Copy link
Copy Markdown
Owner Author

Edge case: If a user types /permit add <user>, then ignores the info message that authentication is needed and then /permit add <user> is executed again (either by the user themselves or by another user), the commands do not get reloaded (as in: the changes are not applied immediately)

@TrojanerHD

Copy link
Copy Markdown
Owner Author

Refresh tokens sometimes do not get stored and the whole permission system doesn't seem to work as the restricted commands don't get any custom roles that are permitted to execute them

Comment thread src/FeatureChecker.ts
streamers: [],
refreshToken: '',
}).catch(console.error);
} else this.warning(`Limited features due to problems ${guildInfo}`);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove a guild from the safe guilds if there was a problem to make this function safe when re-executing

Comment thread src/FeatureChecker.ts
);
} finally {
if (!error) {
DiscordClient._safeGuilds.push(guild);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if safe guilds doesn't already have this guild to make this function safe when re-executing

* @param data The data to insert or update
*/
protected async upsert(tableName: string, data: T): Promise<void> {
const id = data.id;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const id = data.id;
const { id } = data;

Comment on lines +97 to +101
if (i !== -1) {
this.#cache[i].info = data;
} else {
this.#cache.push({ id, info: data });
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (i !== -1) {
this.#cache[i].info = data;
} else {
this.#cache.push({ id, info: data });
}
if (i !== -1)
this.#cache[i].info = data;
else
this.#cache.push({ id, info: data });

Comment thread README.md
@@ -1,5 +1,16 @@
# Trojaner Bot
This is a [Discord](https://discord.com) bot currently only running on my [Discord server](https://discord.gg/NdsmmwV). There is no official way of adding this bot to your own Discord server.
This is a [Discord](https://discord.com) bot currently only running on my [Discord server](https://discord.gg/NdsmmwV). To add this bot on your server, use the following link:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is a [Discord](https://discord.com) bot currently only running on my [Discord server](https://discord.gg/NdsmmwV). To add this bot on your server, use the following link:
This is a [Discord](https://discord.com) bot currently only running on my [Discord server](https://discord.gg/NdsmmwV). To add this bot on your server, follow these steps:

Comment thread README.md
## Adding the bot to your server
1. Click the following link: https://discord.com/api/oauth2/authorize?client_id=632637013475983360&permissions=8&scope=bot%20applications.commands
- Note that the bot is added with admin privileges. You may alter the permissions value but keep in mind that some features might not work or lead to unexpected behavior
2. (Optional, can be done later) Set up the following text-channels

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. (Optional, can be done later) Set up the following text-channels
2. (Optional, can be done later) Set up the following text-channels:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

When redeploying commands while not having authorized to update command permissions, the bot crashes Configs for each server

1 participant