-
-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update .env.example, .gitignore, NodeConnect.ts, and Lavamusic.ts
- Loading branch information
Showing
10 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ | |
/Lavalink/application.yml | ||
|
||
/Lavalink/plugins | ||
|
||
lavamusic.db | ||
lavamusic.db-shm | ||
lavamusic.db-wal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Event, Lavamusic } from '../../structures/index.js'; | ||
import BotLog from '../../utils/BotLog.js'; | ||
|
||
export default class NodeDestroy extends Event { | ||
constructor(client: Lavamusic, file: string) { | ||
super(client, file, { | ||
name: 'nodeDestroy', | ||
}); | ||
} | ||
public async run(node: string, code: number, reason: string): Promise<void> { | ||
this.client.logger.error(`Node ${node} destroyed with code ${code} and reason ${reason}`); | ||
BotLog.send(this.client, `Node ${node} destroyed with code ${code} and reason ${reason}`, 'error') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Event, Lavamusic } from '../../structures/index.js'; | ||
import BotLog from '../../utils/BotLog.js'; | ||
|
||
export default class NodeDisconnect extends Event { | ||
constructor(client: Lavamusic, file: string) { | ||
super(client, file, { | ||
name: 'nodeDisconnect', | ||
}); | ||
} | ||
public async run(node: string, count: number): Promise<void> { | ||
this.client.logger.warn(`Node ${node} disconnected ${count} times`); | ||
BotLog.send(this.client, `Node ${node} disconnected ${count} times`, 'warn') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Event, Lavamusic } from '../../structures/index.js'; | ||
import BotLog from '../../utils/BotLog.js'; | ||
|
||
export default class NodeError extends Event { | ||
constructor(client: Lavamusic, file: string) { | ||
super(client, file, { | ||
name: 'nodeError', | ||
}); | ||
} | ||
public async run(node: string, error: any): Promise<void> { | ||
this.client.logger.error(`Node ${node} Error: ${JSON.stringify(error)}`); | ||
BotLog.send(this.client, `Node ${node} Error: ${JSON.stringify(error)}`, 'error') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Event, Lavamusic } from '../../structures/index.js'; | ||
|
||
|
||
export default class NodeRaw extends Event { | ||
constructor(client: Lavamusic, file: string) { | ||
super(client, file, { | ||
name: 'nodeRaw', | ||
}); | ||
} | ||
public async run(payload: any): Promise<void> { | ||
//this.client.logger.debug(`Node raw event: ${JSON.stringify(payload)}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Event, Lavamusic } from '../../structures/index.js'; | ||
import BotLog from '../../utils/BotLog.js'; | ||
|
||
export default class NodeReconnect extends Event { | ||
constructor(client: Lavamusic, file: string) { | ||
super(client, file, { | ||
name: 'nodeReconnect', | ||
}); | ||
} | ||
public async run(node: string): Promise<void> { | ||
this.client.logger.warn(`Node ${node} reconnected`); | ||
BotLog.send(this.client, `Node ${node} reconnected`, 'warn') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TextChannel } from 'discord.js'; | ||
import { Lavamusic } from '../structures/index.js'; | ||
|
||
|
||
export default class BotLog { | ||
public static send(client: Lavamusic, message: string, type: string): void { | ||
if (!client) return; | ||
if (!client.channels.cache) return; | ||
if (!client.config.logChannelId) return; | ||
const channel = client.channels.cache.get(client.config.logChannelId) as TextChannel; | ||
if (!channel) return; | ||
let color: string | number | readonly [red: number, green: number, blue: number]; | ||
switch (type) { | ||
case 'error': | ||
color = 0xff0000; | ||
break; | ||
case 'warn': | ||
color = 0xffff00; | ||
break; | ||
case 'info': | ||
color = 0x00ff00; | ||
break; | ||
case 'success': | ||
color = 0x00ff00; | ||
break; | ||
default: | ||
color = 0x000000; | ||
break; | ||
} | ||
const embed = client.embed() | ||
.setColor(color) | ||
.setDescription(message) | ||
.setTimestamp(); | ||
|
||
channel.send({ embeds: [embed] }).catch(() => {null}); | ||
} | ||
} |