(v4.1.2) Massive permission system cleanup
This commit is contained in:
+15
-1
@@ -44,21 +44,35 @@ export const registerCommandResponders = async () => {
|
||||
}
|
||||
}),
|
||||
new api.ODWorker("opendiscord:pin",0,async (instance,params,source,cancel) => {
|
||||
const {guild,channel,user} = instance
|
||||
const {guild,channel,user,member} = instance
|
||||
|
||||
//check permissions
|
||||
const permsResult = await opendiscord.permissions.checkCommandPerms(generalConfig.data.system.permissions.pin,"support",user,member,channel,guild)
|
||||
if (!permsResult.hasPerms){
|
||||
if (permsResult.reason == "not-in-server") await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-not-in-guild").build("button",{channel,user}))
|
||||
else await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-no-permissions").build(source,{guild,channel,user,permissions:["support"]}))
|
||||
return cancel()
|
||||
}
|
||||
|
||||
//check is in guild/server
|
||||
if (!guild){
|
||||
instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-not-in-guild").build("button",{channel,user}))
|
||||
return cancel()
|
||||
}
|
||||
|
||||
//check if ticket exists
|
||||
const ticket = opendiscord.tickets.get(channel.id)
|
||||
if (!ticket || channel.isDMBased()){
|
||||
instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-ticket-unknown").build("button",{guild,channel,user}))
|
||||
return cancel()
|
||||
}
|
||||
|
||||
//return when already pinned
|
||||
if (ticket.get("opendiscord:pinned").value){
|
||||
instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error").build("button",{guild,channel,user,error:opendiscord.languages.getTranslation("errors.actionInvalid.pin"),layout:"simple"}))
|
||||
return cancel()
|
||||
}
|
||||
|
||||
//return when busy
|
||||
if (ticket.get("opendiscord:busy").value){
|
||||
instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-ticket-busy").build("button",{guild,channel,user}))
|
||||
|
||||
Reference in New Issue
Block a user