1 |
import { CommandInteraction, GuildMember, Message, Role, User } from "discord.js"; |
import { CommandInteraction, Guild, GuildMember, Message, Role, User, MessageMentions } from "discord.js"; |
2 |
import CommandOptions from "../types/CommandOptions"; |
import CommandOptions from "../types/CommandOptions"; |
3 |
|
|
4 |
export default async function getRole(msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<Role | null | undefined> { |
export default async function getRole(msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<Role | null | undefined> { |
11 |
const arg = await options.normalArgs[index]; |
const arg = await options.normalArgs[index]; |
12 |
|
|
13 |
return await msgInteraction.guild?.roles.fetch(arg); |
return await msgInteraction.guild?.roles.fetch(arg); |
14 |
|
} |
15 |
|
|
16 |
|
export async function getRoleRaw(roleString: string, guild: Guild): Promise<Role | null | undefined> { |
17 |
|
if (roleString === '@everyone') |
18 |
|
return guild.roles.everyone; |
19 |
|
else if (MessageMentions.ROLES_PATTERN.test(roleString)) { |
20 |
|
roleString = roleString.substring(3, roleString.length - 1); |
21 |
|
} |
22 |
|
|
23 |
|
console.log(roleString); |
24 |
|
return await guild.roles.fetch(roleString); |
25 |
} |
} |