Merge remote-tracking branch 'origin/main' into slash

This commit is contained in:
DjDeveloperr 2021-01-29 14:59:02 +05:30
commit aa5075451b
5 changed files with 38 additions and 8 deletions

View File

@ -319,9 +319,7 @@ export class RESTManager {
}
}
const form = new FormData()
for (const file of files) {
form.append(file.name, file.blob, file.name)
}
files.forEach((file, index) => form.append(`file${index + 1}`, file.blob, file.name))
const json = JSON.stringify(body)
form.append('payload_json', json)
if (body === undefined) body = {}

View File

@ -18,7 +18,7 @@ export interface MemberData {
export class Member extends SnowflakeBase {
id: string
user: User
nick?: string
nick: string | null
roles: MemberRolesManager
joinedAt: string
premiumSince?: string
@ -49,7 +49,7 @@ export class Member extends SnowflakeBase {
}
get displayName(): string {
return this.nick !== undefined ? this.nick : this.user.username
return this.nick !== null ? this.nick : this.user.username
}
toString(): string {
@ -95,7 +95,7 @@ export class Member extends SnowflakeBase {
)
if (res.ok === true) {
if (data.nick !== undefined)
this.nick = data.nick === null ? undefined : data.nick
this.nick = data.nick === null ? null : data.nick
if (data.deaf !== undefined) this.deaf = data.deaf
if (data.mute !== undefined) this.mute = data.mute
}

View File

@ -13,6 +13,7 @@ import {
} from '../../mod.ts'
import { Collector } from '../models/collectors.ts'
import { MessageAttachment } from '../structures/message.ts'
import { Permissions } from '../utils/permissions.ts'
import { TOKEN } from './config.ts'
const client = new Client({
@ -179,6 +180,37 @@ client.on('messageCreate', async (msg: Message) => {
const vs = await msg.guild?.voiceStates.get(msg.member.id)
if (typeof vs !== 'object') return
vs.channel?.join()
} else if (msg.content === '!getOverwrites') {
if (msg.channel.type !== ChannelTypes.GUILD_TEXT) {
return msg.channel.send("This isn't a guild text channel!")
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const overwrites = await (msg.channel as GuildTextChannel).overwritesFor(
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
msg.member as Member
)
msg.channel.send(
`Your permission overwrites:\n${overwrites
.map(
(over) =>
`ID: ${over.id}\nAllowed:\n${new Permissions(over.allow)
.toArray()
.join('\n')}\nDenied:\n${new Permissions(over.deny)
.toArray()
.join('\n')}`
)
.join('\n\n')}`
)
} else if (msg.content === '!getPermissions') {
if (msg.channel.type !== ChannelTypes.GUILD_TEXT) {
return msg.channel.send("This isn't a guild text channel!")
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const permissions = await (msg.channel as GuildTextChannel).permissionsFor(
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
msg.member as Member
)
msg.channel.send(`Your permissions:\n${permissions.toArray().join('\n')}`)
}
})

View File

@ -212,7 +212,7 @@ export interface GuildMemberUpdatePayload {
guild_id: string
roles: string[]
user: UserPayload
nick?: string | undefined
nick: string | null
joined_at: string
premium_since?: string | undefined
}

View File

@ -67,7 +67,7 @@ export interface GuildPayload {
export interface MemberPayload {
user: UserPayload
nick?: string
nick: string | null
roles: string[]
joined_at: string
premium_since?: string