Skip to content

Commit

Permalink
3.0.0-dev-6
Browse files Browse the repository at this point in the history
Reworked /report command, now it gives a link to issues or discussions.
Removed modal handling.
Command //setPrefix now accepts prefix with length of two characters.
Added wiki page for Commands.
Command audiodebug available only for overpowered user.
  • Loading branch information
AlexInCube committed Jul 6, 2024
1 parent 48612b0 commit 64f77ac
Show file tree
Hide file tree
Showing 23 changed files with 204 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Cool audiobot for Discord created by <a href="https://vk.com/alexincube"><b>@Ale

## 🌟 Features
- Command /alcotest which shows your alcohol count in blood
- Audioplayer based on [Distube](https://github.com/skick1234/DisTube) with buttons ![image](https://i.imgur.com/zqQ6ViY.png)
- Audioplayer based on [Distube](https://github.com/skick1234/DisTube) with buttons ![play-audioplayer](/wiki/images/commands/play-audioplayer.png)
- Support YouTube, Spotify, Soundcloud, any HTTP-stream and Discord Attachments (/playfile support MP3/WAV/OGG)
- Support Slash and Text commands (with customizable prefix per server using /setprefix)
- Localization (English and Russian are currently supported)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aicbot",
"version": "3.0.0-dev-5",
"version": "3.0.0-dev-6",
"description": "Discord Bot for playing music",
"main": "build/main.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/admin/setPrefix.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function (): ICommand {
text_data: {
name: 'setprefix',
description: i18next.t('commands:set_prefix_desc'),
arguments: [new CommandArgument('символ', true)],
arguments: [new CommandArgument('newprefix', true)],
execute: async (message: Message, args: string[]): Promise<void> => {
const prefix: string = args[0];
if (!prefix) return;
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function (): ICommand {
async function changePrefixTo(guild: Guild, prefix: string): Promise<string> {
if (prefix === '/' || prefix === '@' || prefix === '#')
return i18next.t('commands:set_prefix_restrict_prefixes', { prefixes: '/ @ #' }) as string;
if (prefix.length > 1) return i18next.t('commands:set_prefix_length_error') as string;
if (prefix.length > 2) return i18next.t('commands:set_prefix_length_error') as string;
await setGuildOption(guild, 'prefix', prefix);
return i18next.t('commands:set_prefix_success_change', { prefix: prefix }) as string;
}
3 changes: 3 additions & 0 deletions src/commands/audio/audiodebug.command.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { ICommand } from '../../CommandTypes.js';
import { PermissionsBitField } from 'discord.js';
import { GroupAudio } from './AudioTypes.js';
import { isOverpoweredUser } from '../../utilities/isOverpoweredUser.js';

export default function (): ICommand {
return {
text_data: {
name: 'audiodebug',
description: 'Debug info about audioplayers',
execute: async (message) => {
if (!isOverpoweredUser(message.author.id)) return;

await message.reply({
content: message.client.audioPlayer.playersManager.debug(),
allowedMentions: { users: [] }
Expand Down
38 changes: 11 additions & 27 deletions src/commands/info/report.command.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
import { ICommand } from '../../CommandTypes.js';
import {
ActionRowBuilder,
ChatInputCommandInteraction,
Message,
ModalActionRowComponentBuilder,
ModalBuilder,
PermissionsBitField,
SlashCommandBuilder,
TextInputBuilder,
TextInputStyle
SlashCommandBuilder
} from 'discord.js';
import { GroupInfo } from './InfoTypes.js';
import i18next from 'i18next';
import { generateSimpleEmbed } from '../../utilities/generateSimpleEmbed.js';

export default function (): ICommand {
return {
text_data: {
name: 'report',
description: i18next.t('commands:report_desc'),
execute: async (message: Message) => {
await message.reply(i18next.t('commands:report_text_error') as string);
await message.reply({ embeds: [generateReportEmbed()] });
}
},
slash_data: {
slash_builder: new SlashCommandBuilder()
.setName('report')
.setDescription(i18next.t('commands:report_desc')),
execute: async (interaction: ChatInputCommandInteraction) => {
await interaction.showModal(generateModalWindow());
await interaction.reply({ embeds: [generateReportEmbed()], ephemeral: true });
}
},
group: GroupInfo,
bot_permissions: [PermissionsBitField.Flags.SendMessages]
};
}

function generateModalWindow() {
const modal = new ModalBuilder()
.setCustomId('reportModal')
.setTitle(i18next.t('commands:report_modal_title'));

const reportInput = new TextInputBuilder()
.setCustomId('reportInput')
.setLabel(i18next.t('commands:report_modal_text_label'))
.setStyle(TextInputStyle.Paragraph)
.setMinLength(20)
.setPlaceholder(i18next.t('commands:report_modal_text_placeholder'))
.setRequired(true);

const firstActionRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
reportInput
function generateReportEmbed() {
return generateSimpleEmbed(
i18next.t('commands:report_message', {
issueLink: 'https://github.com/AlexInCube/AlCoTest/issues/new/choose',
discussionLink: 'https://github.com/AlexInCube/AlCoTest/discussions/new?category=q-a',
interpolation: { escapeValue: false }
})
);

modal.addComponents(firstActionRow);

return modal;
}
2 changes: 0 additions & 2 deletions src/events/interactionCreate.event.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { BotEvent } from '../Types.js';
import { slashCommandHandler } from './interactionHandlers/slashCommandHandler.js';
import { autocompleteHandler } from './interactionHandlers/autocompleteHandler.js';
import { modalsHandler } from './interactionHandlers/modalsHandler.js';
import { Client, Events, Interaction } from 'discord.js';

const event: BotEvent = {
name: Events.InteractionCreate,
execute: async (client: Client, interaction: Interaction) => {
await slashCommandHandler(interaction);
await autocompleteHandler(interaction);
await modalsHandler(interaction);
}
};

Expand Down
23 changes: 0 additions & 23 deletions src/events/interactionHandlers/modalsHandler.ts

This file was deleted.

10 changes: 3 additions & 7 deletions src/locales/en/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"set_prefix_desc": "Change prefix for TEXT commands and only for current server",
"set_prefix_arg_newprefix_desc": "Don't forget to inform the other server members about the changed prefix",
"set_prefix_restrict_prefixes": "You can't specify characters {{prefixes}} as a prefix",
"set_prefix_length_error": "The prefix cannot be longer than one character",
"set_prefix_length_error": "The prefix cannot be longer than two characters",
"set_prefix_success_change": "Prefix successful changed on this server to {{prefix}}",
"help_desc": "Commands list",
"help_arg_command": "command name",
Expand Down Expand Up @@ -56,12 +56,8 @@
"stop_success": "turned off the audioplayer",
"alcotest_desc": "Writes the percentage of beer in your blood",
"alcotest_success": "You are consisting of beer on the",
"report_desc": "Opens a modal window for sending a message to the developer",
"report_text_error": "Unfortunately, this command only works if it is called with /. So write /report",
"report_modal_title": "Creating a wish/complaint",
"report_modal_text_label": "What functionality to add or what to fix",
"report_modal_text_placeholder": "Describe clearly and precisely",
"report_modal_feedback": "Maybe I'll listen to you.",
"report_desc": "Return links to Github Issues or GitHub Discussions",
"report_message": "Create [Issue]({{issueLink}}) or [Discussion]({{discussionLink}})",
"status_desc": "View bot status",
"status_embed_title": "Bot status",
"status_embed_bot_version": "Bot version",
Expand Down
10 changes: 3 additions & 7 deletions src/locales/ru/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"set_prefix_desc": "Меняет префикс для ТЕКСТОВЫХ команд и только для текущего сервера",
"set_prefix_arg_newprefix_desc": "Не забудьте сообщить остальным участникам сервера об изменённом префиксе",
"set_prefix_restrict_prefixes": "Нельзя указывать символы {{prefixes}} в качестве префикса",
"set_prefix_length_error": "Префикс не может быть длиннее одного символа",
"set_prefix_length_error": "Префикс не может быть длиннее двух символов",
"set_prefix_success_change": "Префикс на этом сервере успешно изменён на {{prefix}}",
"help_desc": "Список команд",
"help_arg_command": "название команды",
Expand Down Expand Up @@ -56,12 +56,8 @@
"stop_success": "выключил(-а) плеер",
"alcotest_desc": "Пишет процент пива в твоей крови",
"alcotest_success": "Вы состоите из пива на",
"report_desc": "Открывает окно для отправки сообщения разработчику",
"report_text_error": "К сожалению эта команда работает только если она вызвана через /. Так что напишите /report",
"report_modal_title": "Создание пожелания/жалобы",
"report_modal_text_label": "Какой функционал добавить или что исправить",
"report_modal_text_placeholder": "Описывайте ясно и чётко",
"report_modal_feedback": "Возможно я к тебе прислушаюсь",
"report_desc": "Возвращает ссылки на Github Issues или Github Discussions",
"report_message": "Создайте [Issue]({{issueLink}}) или [Discussion]({{discussionLink}})",
"status_desc": "Просмотр состояния бота",
"status_embed_title": "Состояние бота",
"status_embed_bot_version": "Версия бота",
Expand Down
5 changes: 5 additions & 0 deletions src/utilities/isOverpoweredUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ENV } from '../EnvironmentVariables.js';

export function isOverpoweredUser(userId: string): boolean {
return userId === ENV.BOT_DISCORD_OVERPOWERED_ID;
}
26 changes: 13 additions & 13 deletions wiki/API-Configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
> Don't share this API data with anyone because you can get compromised.
> If this happens, reset the tokens and get them again.
## Discord Developer Portal (required)
# Discord Developer Portal (required)

1. Open the [Discord Developer Portal](https://discord.com/developers/applications) and log into your account.
2. Click on the "New Application" button.
3. Enter a name and confirm the pop-up window by clicking the "Create" button.

You should see a page like this:

![discord-dev-selected-app](./images/discord-dev-selected-app.png)
![discord-dev-selected-app](images/api-configure/discord-dev-selected-app.png)

You can edit your application's name, description, and avatar here. Once you've done that, then congratulations—you're now the proud owner of a shiny new Discord bot! You're not entirely done, though.

Expand All @@ -19,9 +19,9 @@ You can edit your application's name, description, and avatar here. Once you've
6. Press "Reset token" button and copy token.
7. Also enable all "Privileged Gateway Intents"

![discord-dev-enable-intents](./images/discord-dev-enable-intents.png)
![discord-dev-enable-intents](images/api-configure/discord-dev-enable-intents.png)

## YouTube Cookie (optional)
# YouTube Cookie (optional)
Preferable to provide cookies for YouTube.
This will allow you to play 18+ videos and bypass YouTube rate limiting error (429 Error).
I highly recommend that you create a new Google account from which you can get the cookie.
Expand All @@ -37,38 +37,38 @@ I highly recommend that you create a new Google account from which you can get t
4. Click on the extension icon and click "Export" button.
5. Create file yt-cookies.json and paste cookie in this file

## Yandex Music (optional)
# Yandex Music (optional)
If you do not provide token and UID, Yandex Music will not work at all.

> [!WARNING]
> If your bot is outside Russia VDS, you must have a Yandex Plus subscription to play songs.
### Token
## Token
1. Login into [Yandex](https://passport.yandex.ru/auth) account.
2. Download [browser extension](https://chromewebstore.google.com/detail/yandex-music-token/lcbjeookjibfhjjopieifgjnhlegmkib)
This must look like this ![yandex-extension](./images/yandex-music-extension.png)
This must look like this ![yandex-extension](images/api-configure/yandex-music-extension.png)
3. Click "Скопировать токен" button.

### UID
## UID
1. Login into [Yandex](https://passport.yandex.ru/auth) account.
2. You can retrieve uid by opening [Yandex Mail](https://mail.yandex.ru) and copy uid from the url in the address bar.
![yandex-uid](./images/yandex-music-uid.png)
![yandex-uid](images/api-configure/yandex-music-uid.png)

## Spotify (optional)
# Spotify (optional)
Spotify Module can work without provided data, but for more stability better provide custom application data.

> [!WARNING]
> If you want to fetch playlist with more than 100 songs, this API data is required!
1. Login in [Spotify Developer Dashboard](https://developer.spotify.com/dashboard)
2. Press "Create app" button![Spotify Dev Main](images/spotify-dev-main.png)
3. Fill the fields like this![Spotify Dev Create App](./images/spotify-dev-create-app.png)
2. Press "Create app" button![Spotify Dev Main](images/api-configure/spotify-dev-main.png)
3. Fill the fields like this![Spotify Dev Create App](images/api-configure/spotify-dev-create-app.png)
4. Press "Save"
5. On the redirected page, press "Settings"
6. On "Basic Information" section copy Client ID.
7. Under the Client ID field, press "View Client Secret" and copy Client Secret.

## Soundcloud (optional)
# Soundcloud (optional)

1. Go to [SoundCloud](https://soundcloud.com) and login.
2. Open up the dev tools (Right-click -> inspect) and go to the Network tab.
Expand Down
Loading

0 comments on commit 64f77ac

Please sign in to comment.