Oreo ™
Oreo ™
SIASapphire - Imagine a framework
Created by Oreo ™ on 1/14/2024 in #sapphire-support
Subcommands Refusing to work for anyone but me?
No description
22 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 1/5/2024 in #sapphire-support
Is it possible to send an image using `plugin-api`
I have a leveling bot and a dashboard for it, i was wondering if there was a way to get the users rank card from the api instead of generating the image on the dashboard.
13 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 12/11/2023 in #sapphire-support
API Authentication not working
Hey, its me again. Okay so i followed the sapphire docs and made the authenticated precondition be
export const authenticated = () =>
createFunctionPrecondition(
(request: ApiRequest) => Boolean(request.auth?.token),
(_request: ApiRequest, response: ApiResponse) => response.error(HttpCodes.Unauthorized)
);
export const authenticated = () =>
createFunctionPrecondition(
(request: ApiRequest) => Boolean(request.auth?.token),
(_request: ApiRequest, response: ApiResponse) => response.error(HttpCodes.Unauthorized)
);
and i make the api call to refresh/fetch a user from the endpoint users/@me but i get { error: "Cannot read properties of null (reading 'id')" } when i log the response data returned here so that means auth is null? i have credentials: 'include' in the request tho
23 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 12/9/2023 in #sapphire-support
Setting up oauth API
my dashboard is hosted on https://cardinal.oreotm.xyz and my backend is hosted on a vps on [ipaddress] Backend Setup:
auth: {
id: BotClientID,
secret: envParseString('OAUTH_SECRET'),
cookie: 'CARDINAL_AUTH', //envParseString('OAUTH_COOKIE'),
redirect: 'https://cardinal.oreotm.xyz/oauth/discord/callback', // envParseString('OAUTH_REDIRECT_URI')
scopes: [OAuth2Scopes.Identify, OAuth2Scopes.Guilds],
transformers: [transformOauthGuildsAndUser],
domainOverwrite: '.oreotm.xyz' //envParseString('OAUTH_DOMAIN_OVERWRITE')
},
prefix: '/', //envParseString('API_PREFIX'),
origin: 'https://cardinal.oreotm.xyz', //envParseString('API_ORIGIN'),
listenOptions: {
port: 4000
}
auth: {
id: BotClientID,
secret: envParseString('OAUTH_SECRET'),
cookie: 'CARDINAL_AUTH', //envParseString('OAUTH_COOKIE'),
redirect: 'https://cardinal.oreotm.xyz/oauth/discord/callback', // envParseString('OAUTH_REDIRECT_URI')
scopes: [OAuth2Scopes.Identify, OAuth2Scopes.Guilds],
transformers: [transformOauthGuildsAndUser],
domainOverwrite: '.oreotm.xyz' //envParseString('OAUTH_DOMAIN_OVERWRITE')
},
prefix: '/', //envParseString('API_PREFIX'),
origin: 'https://cardinal.oreotm.xyz', //envParseString('API_ORIGIN'),
listenOptions: {
port: 4000
}
Frontend Code:
const response = await fetch(`${BASE_CARDINAL_API_URL}/oauth/callback`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
redirectUri: REDIRECT_URI
})
});
const response = await fetch(`${BASE_CARDINAL_API_URL}/oauth/callback`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
redirectUri: REDIRECT_URI
})
});
When i host the frontend on my local machine the login data is returned, but when i host the site on the domain it returns 'Bad request'. How do i properly set the api up?
89 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 11/11/2023 in #sapphire-support
Dyno like help command
If i have the help data in every commands detailedDescription value, how can i make it so that when a user runs !<commandName> help it displays the help embed instead of having to run !help <commandName>
8 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 11/5/2023 in #sapphire-support
Manual task not triggering
im trying to create an unmute task but it doesnt seems to get triggered that reliably I also tried copy pasting the documentation code for manual and it also gets triggered rarely here are some snippets of my code UnmuteUserTask.ts https://raw.githubusercontent.com/TheOreoTM/cardinal-bot/main/src/scheduled-tasks/UnmuteMemberTask.ts And i call it in a Class i have named Modlog Modlog.ts
export class Modlog {
// code
public async createMute(data: MuteCreateInput) {
const mute = await container.db.mute.create({
data: {
expiresAt: data.expiresAt,
memberId: this.memberId,
removedRoles: data.removedRoles ? data.removedRoles : [],
modlog: {
create: await this.createModlog()
}
}
});

if (data.expiresAt) {
const offset = data.expiresAt.getTime() - Date.now();
console.log(offset);
container.tasks.create('UnmuteMemberTask', { muteId: mute.id }, offset);
}

await this.sendModlog(mute.modlogId);

return this;
}
// code
}
export class Modlog {
// code
public async createMute(data: MuteCreateInput) {
const mute = await container.db.mute.create({
data: {
expiresAt: data.expiresAt,
memberId: this.memberId,
removedRoles: data.removedRoles ? data.removedRoles : [],
modlog: {
create: await this.createModlog()
}
}
});

if (data.expiresAt) {
const offset = data.expiresAt.getTime() - Date.now();
console.log(offset);
container.tasks.create('UnmuteMemberTask', { muteId: mute.id }, offset);
}

await this.sendModlog(mute.modlogId);

return this;
}
// code
}
and this class is called in the mute command Here my are versions "@sapphire/plugin-scheduled-tasks": "^8.0.0" "@sapphire/framework": "^4.5.1"
12 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 8/30/2023 in #discordjs-support
cant receive dm messages from the 'messageCreate' event even after enabling the channel partial
No description
12 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 8/2/2023 in #sapphire-support
editable commands
Is there anyway i can make it so that when someone edits the command it edits the original response and not send a new message everytime?
56 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 7/29/2023 in #sapphire-support
Augmenting Container Failed
declare module '@sapphire/pieces' {
interface Container {
db: PrismaClient;
}
}
declare module '@sapphire/pieces' {
interface Container {
db: PrismaClient;
}
}
Idk why but this suddenly stopped working after i installed the following packages @sapphire/async-queue @sapphire/fetch @sapphire/pieces @sapphire/discord.js-utilities Everything was working fine before but i think after i installed @sapphire/pieces it broke. I tried reinstallig the node_modules and reloading vscode but nothing seems to work
19 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 4/23/2023 in #sapphire-support
extending Command class
How can i make a class called ModerationCommand which automatically checks if the user is a staff member and if not then returns an error so that i dont have to implement the checking in every moderation command file
22 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 4/11/2023 in #sapphire-support
Cant find the template
53 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 4/10/2023 in #sapphire-support
Argument of type '"Staff"' is not assignable to parameter of type 'SimplePreconditionKeys | Simpl...
24 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 4/4/2023 in #sapphire-support
Having trouble with reporting precondition failure
I am trying to send an error message when a person who isnt the bot owner runs the eval command but i cant get it to work I followed the docs and even copied the example bot but nothing seems to make the thing work. I tried to console.log error.message but that doesnt console.log either Precondition
// OwnerOnly.ts
import { Precondition } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class OwnerOnlyPrecondition extends Precondition {
public override async messageRun(message: Message) {
// for Message Commands
return this.checkOwner(message.author.id);
}

private async checkOwner(userId: string) {
return userId === '600707283097485322'
? this.ok()
: this.error({ message: 'Only the bot owner can use this command!' });
}
}

declare module '@sapphire/framework' {
interface Preconditions {
OwnerOnly: never;
}
}

export default undefined
// OwnerOnly.ts
import { Precondition } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class OwnerOnlyPrecondition extends Precondition {
public override async messageRun(message: Message) {
// for Message Commands
return this.checkOwner(message.author.id);
}

private async checkOwner(userId: string) {
return userId === '600707283097485322'
? this.ok()
: this.error({ message: 'Only the bot owner can use this command!' });
}
}

declare module '@sapphire/framework' {
interface Preconditions {
OwnerOnly: never;
}
}

export default undefined
Listener
// messageCommmandDenied.ts
import type { Events, MessageCommandDeniedPayload } from '@sapphire/framework';
import { Listener, UserError } from '@sapphire/framework';

export class UserEvent extends Listener<typeof Events.MessageCommandDenied> {
public async run(
{ message: content }: UserError,
{ message }: MessageCommandDeniedPayload
) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
console.log(content);
return message.channel.send({
content,
allowedMentions: { users: [message.author.id], roles: [] },
});
}
}
// messageCommmandDenied.ts
import type { Events, MessageCommandDeniedPayload } from '@sapphire/framework';
import { Listener, UserError } from '@sapphire/framework';

export class UserEvent extends Listener<typeof Events.MessageCommandDenied> {
public async run(
{ message: content }: UserError,
{ message }: MessageCommandDeniedPayload
) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
console.log(content);
return message.channel.send({
content,
allowedMentions: { users: [message.author.id], roles: [] },
});
}
}
23 replies
SIASapphire - Imagine a framework
Created by Oreo ™ on 4/4/2023 in #sapphire-support
messagecommand generated from CLI error
No description
30 replies