Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Invite link on readme does not work #127

Merged
merged 2 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Dynamica, a bot designed to replicate the features of the Auto Voice Channels bo

There are a few different ways to run this bot:

1. Let me run the bot for you. [Invite Link](https://discord.com/api/oauth2/authorize?client_id=916643283118198804&permissions=285212688&scope=bot%20applications.commands)
1. Let me run the bot for you. [Invite Link](https://discord.com/api/oauth2/authorize?client_id=916643283118198804&permissions=8&scope=bot%20applications.commands)

2. Clone the repository and run `yarn`, `yarn prisma migrate deploy` then `yarn start`. This will store the database files in the `config` directory. To update simply `git pull` then run `yarn prisma migrate deploy` and then `yarn start`.
2. Clone the repository and run `yarn`, `yarn prisma migrate deploy`, `yarn build`, `yarn deploy` then `yarn start`. This will store the database files in the `config` directory. To update simply `git pull` then run `yarn prisma migrate deploy` and then `yarn start`.

3. The docker image. The easiest way to run this bot would be to either clone the repository and then run `docker-compose up -d`.

Expand All @@ -22,7 +22,16 @@ For both of the above deployment methods there are a few environment variables t

- TOKEN - This is the discord bot token.
- CLIENT_ID - The bot's application or client id.
- GUILD_ID - The Id of the guild where the bot will be running in.
- GUILD_ID - The Id of the guild where the bot will be running in. (optional)
- MQTT_URL - URL of an mqtt server to report basic stats to (optional)
- MQTT_USER - MQTT server username (optional)
- MQTT_PASS - MQTT server password (optional)

### Intents

In order to work correctly the bot needs to be able to read the presence of guild members. Discord has limitted this functionality with **Privileged Gateway Intents**. You need to enable the following intents for the bot to work correctly:

- **Presence Intent** - So that the bot can read user activities and change the channel name based on that

### Slash Commands

Expand Down
20 changes: 3 additions & 17 deletions src/classes/Secondary.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// eslint-disable-next-line import/no-cycle
import channelActivities from '@/utils/activity';
import updatePresence from '@/utils/presence';
import db from '@db';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/index.js';
import formatChannelName from '@utils/format';
import signaleLogger from '@utils/logger';
import {
ActivityType,
ChannelType,
Client,
DiscordAPIError,
Expand Down Expand Up @@ -52,14 +52,7 @@ export default class DynamicaSecondary {
where: { guildId: guild.id },
});

const activities = primary.members
.filter((listMember) => listMember.presence.activities.length > 0)
.filter((listMember) => !listMember.user.bot)
.map((listMember) => listMember.presence.activities)
.flat()
.filter((activity) => activity.type !== ActivityType.Custom)
.filter((activity) => activity.type !== ActivityType.Listening)
.map((activity) => activity.name);
const activities = channelActivities(primary);

const primaryPrisma = await db.primary.findUnique({
where: { id: primary.id },
Expand Down Expand Up @@ -159,14 +152,7 @@ export default class DynamicaSecondary {
/**
* The activities list minus stuff that should be ignored like Spotify and Custom status // Todo: more complicated logic for people who might be streaming
*/
const activities = discordChannel.members
.filter((member) => member.presence.activities.length > 0)
.filter((member) => !member.user.bot)
.map((member) => member.presence.activities)
.flat()
.filter((activity) => activity.type !== ActivityType.Custom)
.filter((activity) => activity.type !== ActivityType.Listening)
.map((activity) => activity.name);
const activities = channelActivities(discordChannel);

const { locked } = prismaChannel;

Expand Down
8 changes: 4 additions & 4 deletions src/utils/activity.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ActivityType, VoiceBasedChannel } from 'discord.js';

const channelActivities = ({ members }: VoiceBasedChannel) =>
members
.filter((member) => member.presence.activities.length > 0)
const channelActivities = (channel: VoiceBasedChannel) =>
channel?.members
.filter((member) => !member.user.bot)
.filter((member) => !!member.presence)
.map((member) => member.presence.activities)
.flat()
.filter((activity) => activity.type !== ActivityType.Custom)
.filter((activity) => activity.type !== ActivityType.Listening)
.map((activity) => activity.name);
.map((activity) => activity.name) ?? [];

export default channelActivities;