mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Merge pull request #39 from Hades785/master
This commit is contained in:
commit
a44798edb1
5 changed files with 52 additions and 7 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -20,7 +20,7 @@
|
|||
"mathjs": "^9.3.0",
|
||||
"moment": "^2.29.1",
|
||||
"ms": "^2.1.3",
|
||||
"onion-lasers": "^1.1.0",
|
||||
"onion-lasers": "^1.1.1",
|
||||
"relevant-urban": "^2.0.0",
|
||||
"translate-google": "^1.4.3",
|
||||
"weather-js": "^2.0.0"
|
||||
|
@ -5140,9 +5140,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/onion-lasers": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.1.tgz",
|
||||
"integrity": "sha512-aX1jZtDMDjXN3N/k5Ca/6N3aQ1ozN6/1iylhbjB9u5xj97KcqhITx8jH5u2JEjUBZRQ3var9PuF1jNz/DrEgdQ==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.2.tgz",
|
||||
"integrity": "sha512-gQHQCdcfDSLeWFFXMTBCy2PZR/n603B+Q2L3vTj+9T1CmJS7OfO7zoFM5QrTkOY4N5hESboOdJ8eRvPXQgdxDg==",
|
||||
"dependencies": {
|
||||
"discord.js": "^12.5.3",
|
||||
"glob": "^7.1.6"
|
||||
|
@ -11845,9 +11845,9 @@
|
|||
}
|
||||
},
|
||||
"onion-lasers": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.1.tgz",
|
||||
"integrity": "sha512-aX1jZtDMDjXN3N/k5Ca/6N3aQ1ozN6/1iylhbjB9u5xj97KcqhITx8jH5u2JEjUBZRQ3var9PuF1jNz/DrEgdQ==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.2.tgz",
|
||||
"integrity": "sha512-gQHQCdcfDSLeWFFXMTBCy2PZR/n603B+Q2L3vTj+9T1CmJS7OfO7zoFM5QrTkOY4N5hESboOdJ8eRvPXQgdxDg==",
|
||||
"requires": {
|
||||
"discord.js": "^12.5.3",
|
||||
"glob": "^7.1.6"
|
||||
|
|
|
@ -204,6 +204,27 @@ export default new NamedCommand({
|
|||
})
|
||||
})
|
||||
}
|
||||
}),
|
||||
name: new NamedCommand({
|
||||
aliases: ["defaultname"],
|
||||
description:
|
||||
"Sets the name that the channel will be reset to once no more members are in the channel.",
|
||||
usage: "(<name>)",
|
||||
run: "Please provide a new voice channel name.",
|
||||
any: new RestCommand({
|
||||
async run({send, guild, message, combined}) {
|
||||
const voiceChannel = message.member?.voice.channel;
|
||||
const guildID = guild!.id;
|
||||
const guildStorage = Storage.getGuild(guildID);
|
||||
const newName = combined;
|
||||
|
||||
if (!voiceChannel) return send("You are not in a voice channel.");
|
||||
|
||||
guildStorage.channelNames[voiceChannel.id] = newName;
|
||||
Storage.save();
|
||||
return await send(`Set default channel name to "${newName}".`);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -74,3 +74,4 @@ import "./modules/intercept";
|
|||
import "./modules/messageEmbed";
|
||||
import "./modules/guildMemberAdd";
|
||||
import "./modules/streamNotifications";
|
||||
import "./modules/channelDefaults";
|
||||
|
|
11
src/modules/channelDefaults.ts
Normal file
11
src/modules/channelDefaults.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import {client} from "../index";
|
||||
import {Storage} from "../structures";
|
||||
|
||||
client.on("voiceStateUpdate", async (before, after) => {
|
||||
const channel = before.channel!;
|
||||
const {channelNames} = Storage.getGuild(after.guild.id);
|
||||
|
||||
if (channel?.members.size === 0 && channel?.id in channelNames) {
|
||||
channel.setName(channelNames[channel.id]);
|
||||
}
|
||||
});
|
|
@ -72,6 +72,7 @@ class Guild {
|
|||
public welcomeMessage: string | null;
|
||||
public streamingChannel: string | null;
|
||||
public streamingRoles: {[role: string]: string}; // Role ID: Category Name
|
||||
public channelNames: {[channel: string]: string};
|
||||
public members: {[id: string]: Member};
|
||||
|
||||
constructor(data?: GenericJSON) {
|
||||
|
@ -80,6 +81,7 @@ class Guild {
|
|||
this.welcomeMessage = select(data?.welcomeMessage, null, String);
|
||||
this.streamingChannel = select(data?.streamingChannel, null, String);
|
||||
this.streamingRoles = {};
|
||||
this.channelNames = {};
|
||||
this.members = {};
|
||||
|
||||
switch (data?.welcomeType) {
|
||||
|
@ -104,6 +106,16 @@ class Guild {
|
|||
}
|
||||
}
|
||||
|
||||
if (data?.channelNames) {
|
||||
for (const id in data.channelNames) {
|
||||
const name = data.channelNames[id];
|
||||
|
||||
if (/\d{17,}/g.test(id) && typeof name === "string") {
|
||||
this.channelNames[id] = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data?.members) {
|
||||
for (let id in data.members) {
|
||||
if (/\d{17,}/g.test(id)) {
|
||||
|
|
Loading…
Reference in a new issue