2020-12-15 01:44:28 +00:00
|
|
|
import Command from "../../core/command";
|
|
|
|
import {CommonLibrary} from "../../core/lib";
|
2020-10-22 14:24:58 +00:00
|
|
|
|
|
|
|
export default new Command({
|
|
|
|
description: "Renames current voice channel.",
|
|
|
|
usage: "<name>",
|
|
|
|
async run($: CommonLibrary): Promise<any> {
|
|
|
|
const voiceChannel = $.message.member?.voice.channel;
|
2020-12-15 01:44:28 +00:00
|
|
|
|
2020-12-15 07:56:09 +00:00
|
|
|
if (!voiceChannel) return $.channel.send("You are not in a voice channel.");
|
2020-12-15 01:44:28 +00:00
|
|
|
|
2021-01-29 16:21:06 +00:00
|
|
|
if (!voiceChannel.guild.me?.hasPermission("MANAGE_CHANNELS"))
|
2020-12-15 07:56:09 +00:00
|
|
|
return $.channel.send("I am lacking the required permissions to perform this action.");
|
2020-12-15 01:44:28 +00:00
|
|
|
|
2020-12-15 07:56:09 +00:00
|
|
|
if ($.args.length === 0) return $.channel.send("Please provide a new voice channel name.");
|
2020-12-15 01:44:28 +00:00
|
|
|
|
2021-01-29 16:21:06 +00:00
|
|
|
const prevName = voiceChannel.name;
|
|
|
|
const newName = $.args.join(" ");
|
|
|
|
await voiceChannel.setName(newName);
|
|
|
|
await $.channel.send(`Changed channel name from "${prevName}" to "${newName}".`);
|
2020-10-22 14:24:58 +00:00
|
|
|
}
|
2020-12-15 01:44:28 +00:00
|
|
|
});
|