Migrate LocateUser to new Plugin structure
This commit is contained in:
parent
4a8a63e8b8
commit
63efaf84ee
16 changed files with 380 additions and 0 deletions
22
backend/src/plugins/LocateUser/utils/sendWhere.ts
Normal file
22
backend/src/plugins/LocateUser/utils/sendWhere.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { Guild, Member, TextableChannel, VoiceChannel } from "eris";
|
||||
import { getInviteLink } from "knub/dist/helpers";
|
||||
import { createOrReuseInvite } from "./createOrReuseInvite";
|
||||
|
||||
export async function sendWhere(guild: Guild, member: Member, channel: TextableChannel, prepend: string) {
|
||||
const voice = guild.channels.get(member.voiceState.channelID) as VoiceChannel;
|
||||
|
||||
if (voice == null) {
|
||||
channel.createMessage(prepend + "That user is not in a channel");
|
||||
} else {
|
||||
let invite = null;
|
||||
try {
|
||||
invite = await createOrReuseInvite(voice);
|
||||
} catch (e) {
|
||||
this.sendErrorMessage(channel, "Cannot create an invite to that channel!");
|
||||
return;
|
||||
}
|
||||
channel.createMessage(
|
||||
prepend + `${member.mention} is in the following channel: \`${voice.name}\` ${getInviteLink(invite)}`,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue