mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Added VRChat commands
This commit is contained in:
@@ -3,6 +3,7 @@ import Configuration from './Configuration';
|
||||
import Prisma from './Prisma';
|
||||
import Discord from './Discord';
|
||||
import osu from './osuAPI';
|
||||
import VRChat from './VRChatAPI';
|
||||
import Express from './Express';
|
||||
|
||||
import Logger from '../libs/Logger';
|
||||
@@ -38,6 +39,11 @@ class App {
|
||||
Locale.init();
|
||||
}
|
||||
|
||||
public loadVRChat(): void {
|
||||
Logger.log('info', 'Loading VRChat');
|
||||
VRChat.init();
|
||||
}
|
||||
|
||||
public load_osu(): void {
|
||||
if (!Environment.get().OSU_API_KEY) {
|
||||
Logger.log('warn', 'OSU_API_KEY is not defined in .env, osu! features will be disabled');
|
||||
|
||||
@@ -25,6 +25,7 @@ import Discord_Say from '../discord/Say';
|
||||
import Discord_InteractionManager from '../discord/InteractionManager';
|
||||
import Discord_MembershipScreening from '../discord/MembershipScreening';
|
||||
import Discord_osu from '../discord/osu';
|
||||
import Discord_VRChat from '../discord/VRChat';
|
||||
import Discord_UserInfo from '../discord/UserInfo';
|
||||
import Discord_Stats from '../discord/Stats';
|
||||
import Discord_Support from '../discord/Support';
|
||||
@@ -78,6 +79,7 @@ class Discord {
|
||||
new Discord_Say(),
|
||||
new Discord_InteractionManager(),
|
||||
new Discord_osu(),
|
||||
new Discord_VRChat(),
|
||||
new Discord_Settings(),
|
||||
new Discord_Support(),
|
||||
|
||||
|
||||
@@ -4,7 +4,15 @@ import validator from 'validator';
|
||||
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
const requiredENV = ['NODE_ENV', 'DATABASE_URL', 'DISCORD_TOKEN', 'PRIVATE_BOT'];
|
||||
const requiredENV = [
|
||||
'NODE_ENV',
|
||||
'DATABASE_URL',
|
||||
'DISCORD_TOKEN',
|
||||
'PRIVATE_BOT',
|
||||
'IMGPROXY_HOST',
|
||||
'IMGPROXY_KEY',
|
||||
'IMGPROXY_SALT'
|
||||
];
|
||||
|
||||
class Environment {
|
||||
public init(): void {
|
||||
@@ -76,6 +84,14 @@ class Environment {
|
||||
const SPOTIFY_REFRESH_TOKEN = process.env.SPOTIFY_REFRESH_TOKEN;
|
||||
const SPOTIFY_CLIENT_MARKET = process.env.SPOTIFY_CLIENT_MARKET;
|
||||
|
||||
const VRC_CONTACT_EMAIL = process.env.VRC_CONTACT_EMAIL;
|
||||
const VRC_API_KEY = process.env.VRC_API_KEY;
|
||||
const VRC_COOKIE = process.env.VRC_COOKIE;
|
||||
|
||||
const IMGPROXY_HOST = process.env.IMGPROXY_HOST;
|
||||
const IMGPROXY_KEY = process.env.IMGPROXY_KEY;
|
||||
const IMGPROXY_SALT = process.env.IMGPROXY_SALT;
|
||||
|
||||
return {
|
||||
NODE_ENV,
|
||||
|
||||
@@ -93,7 +109,15 @@ class Environment {
|
||||
SPOTIFY_CLIENT_ID,
|
||||
SPOTIFY_CLIENT_SECRET,
|
||||
SPOTIFY_REFRESH_TOKEN,
|
||||
SPOTIFY_CLIENT_MARKET
|
||||
SPOTIFY_CLIENT_MARKET,
|
||||
|
||||
VRC_CONTACT_EMAIL,
|
||||
VRC_API_KEY,
|
||||
VRC_COOKIE,
|
||||
|
||||
IMGPROXY_HOST,
|
||||
IMGPROXY_KEY,
|
||||
IMGPROXY_SALT
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Configuration, AuthenticationApi, UsersApi, WorldsApi } from 'vrchat';
|
||||
import Environment from './Environment';
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
import App from './App';
|
||||
|
||||
interface VRChatAPIs {
|
||||
AuthenticationApi: AuthenticationApi;
|
||||
UsersApi: UsersApi;
|
||||
WorldsApi: WorldsApi;
|
||||
}
|
||||
|
||||
class VRChatAPI {
|
||||
public client: VRChatAPIs | null;
|
||||
public configuration: Configuration | null;
|
||||
|
||||
constructor() {
|
||||
this.client = null;
|
||||
this.configuration = null;
|
||||
}
|
||||
|
||||
public async init() {
|
||||
this.configuration = new Configuration({
|
||||
//username: Environment.get().VRC_USERNAME,
|
||||
//;password: Environment.get().VRC_PASSWORD,
|
||||
apiKey: Environment.get().VRC_API_KEY,
|
||||
baseOptions: {
|
||||
headers: {
|
||||
'User-Agent': `Yumi/${App.version.replaceAll('/', '').replaceAll(' ', '-').replaceAll('--', '-')} ${
|
||||
Environment.get().VRC_CONTACT_EMAIL
|
||||
}`,
|
||||
'Content-Type': 'application/json',
|
||||
Cookie: Environment.get().VRC_COOKIE || ''
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.client = {
|
||||
AuthenticationApi: new AuthenticationApi(this.configuration),
|
||||
UsersApi: new UsersApi(this.configuration),
|
||||
WorldsApi: new WorldsApi(this.configuration)
|
||||
};
|
||||
|
||||
Logger.info('Logging in to VRChat');
|
||||
let res = await this.client.AuthenticationApi.getCurrentUser();
|
||||
|
||||
Logger.info('Logged in to VRChat as ' + res.data.displayName);
|
||||
}
|
||||
|
||||
public end(): void {}
|
||||
}
|
||||
|
||||
export default new VRChatAPI();
|
||||
Reference in New Issue
Block a user