mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 14:30:22 +00:00
style: fixed null checks
This commit is contained in:
parent
9e30a5ee5f
commit
d4b55eae60
@ -313,9 +313,14 @@ const Bots: NextPage<BotsProps> = ({ data, desc, date, user, theme, csrfToken })
|
|||||||
export const getServerSideProps = async (ctx: Context) => {
|
export const getServerSideProps = async (ctx: Context) => {
|
||||||
const parsed = parseCookie(ctx.req)
|
const parsed = parseCookie(ctx.req)
|
||||||
const data = await get.bot.load(ctx.query.id)
|
const data = await get.bot.load(ctx.query.id)
|
||||||
|
if(!data) return {
|
||||||
|
props: {
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
const desc = await get.botDescSafe(data.id)
|
const desc = await get.botDescSafe(data.id)
|
||||||
const user = await get.Authorization(parsed?.token)
|
const user = await get.Authorization(parsed?.token)
|
||||||
if(data && (checkBotFlag(data.flags, 'trusted') || checkBotFlag(data.flags, 'partnered')) && data?.vanity && data.vanity !== ctx.query.id) {
|
if((checkBotFlag(data.flags, 'trusted') || checkBotFlag(data.flags, 'partnered')) && data.vanity && data.vanity !== ctx.query.id) {
|
||||||
ctx.res.statusCode = 301
|
ctx.res.statusCode = 301
|
||||||
ctx.res.setHeader('Location', `/bots/${data.vanity}`)
|
ctx.res.setHeader('Location', `/bots/${data.vanity}`)
|
||||||
return {
|
return {
|
||||||
@ -324,7 +329,7 @@ export const getServerSideProps = async (ctx: Context) => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
data: data ?? { id: '' },
|
data,
|
||||||
desc,
|
desc,
|
||||||
date: SnowflakeUtil.deconstruct(data.id ?? '0').date.toJSON(),
|
date: SnowflakeUtil.deconstruct(data.id ?? '0').date.toJSON(),
|
||||||
user: await get.user.load(user || ''),
|
user: await get.user.load(user || ''),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user