1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-28 08:55:38 -05:00

Revamp guild registration and add other stuff.

This commit is contained in:
toast-ts 2023-02-03 02:45:48 +11:00
parent b67e9a6914
commit 7fc32bdfed
4 changed files with 73 additions and 5 deletions

View File

@ -88,6 +88,36 @@ export default {
client.statsGraph = -(interaction.options.getInteger('number', true))
interaction.reply(`Successfully set to \`${client.statsGraph}\`\n*Total data points: **${JSON.parse(readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).length.toLocaleString()}***`);
break
case 'presence':
function convertType(Type?: number){
switch (Type) {
case 0: return 'Playing';
case 1: return 'Streaming';
case 2: return 'Listening to';
case 3: return 'Watching';
case 5: return 'Competing in';
}
};
const status = interaction.options.getString('status') as Discord.PresenceStatusData | null;
const type = interaction.options.getInteger('type');
const name = interaction.options.getString('name');
const url = interaction.options.getString('url');
const currentActivities = client.config.botPresence.activities as Discord.ActivitiesOptions[];
if (status) client.config.botPresence.status = status;
if (type) currentActivities[0].type = type;
if (name) currentActivities[0].name = name;
if (url) currentActivities[0].url = url;
client.user.setPresence(client.config.botPresence);
interaction.reply([
'Presence updated:',
`Status: **${client.config.botPresence.status}**`,
`Type: **${convertType(currentActivities[0].type)}**`,
`Name: **${currentActivities[0].name}**`,
`URL: \`${currentActivities[0].url}\``
].join('\n'))
break
}
},
data: new SlashCommandBuilder()
@ -116,4 +146,32 @@ export default {
.setName('number')
.setDescription('Number of data points to pull')
.setRequired(true)))
.addSubcommand((optt)=>optt
.setName('presence')
.setDescription('Update the bot\'s presence')
.addIntegerOption((hiTae)=>hiTae
.setName('type')
.setDescription('Set an activity type')
.addChoices(
{name: 'Playing', value: Discord.ActivityType.Playing},
{name: 'Streaming', value: Discord.ActivityType.Streaming},
{name: 'Listening to', value: Discord.ActivityType.Listening},
{name: 'Watching', value: Discord.ActivityType.Watching},
{name: 'Competing in', value: Discord.ActivityType.Competing}
))
.addStringOption((hiAgain)=>hiAgain
.setName('name')
.setDescription('Set a message for the activity status'))
.addStringOption((hiAgainx2)=>hiAgainx2
.setName('url')
.setDescription('Set an url for streaming status'))
.addStringOption((hiAgainx3)=>hiAgainx3
.setName('status')
.setDescription('Set a status indicator for the bot')
.setChoices(
{name: 'Online', value: Discord.PresenceUpdateStatus.Online},
{name: 'Idle', value: Discord.PresenceUpdateStatus.Idle},
{name: 'Do Not Distrub', value: Discord.PresenceUpdateStatus.DoNotDisturb},
{name: 'Invisible', value: Discord.PresenceUpdateStatus.Offline}
)))
}

View File

@ -7,6 +7,9 @@
"embedColorBCA": "#ff69b4",
"embedColorXmas": "#FFFFFF",
"LRSstart": 1661236321433,
"whitelistedServers": [
"929807948748832798", "468835415093411861", "1058183358267543552"
],
"botSwitches": {
"registerCommands": true,
"commands": true,
@ -15,6 +18,12 @@
"mpstats": true,
"autores": true
},
"botPresence": {
"activities": [
{"name": "the days go by", "url": "https://www.youtube.com/watch?v=8UVNT4wvIGY", "type": 1}
],
"status": "online"
},
"eval": {
"allowed": true,
"whitelist": [

View File

@ -9,12 +9,10 @@ import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interf
client.on('ready', async()=>{
client.guilds.cache.forEach(async(e)=>{await e.members.fetch()});
setInterval(async()=>{
client.user.setPresence({activities: [{ name: 'the days go by', type: 3, url: 'https://www.youtube.com/watch?v=D-UmfqFjpl0' }], status: 'online'});
// Playing: 0, Streaming (Requires YT/Twitch URL to work): 1, Listening to: 2, Watching: 3, Competing in: 5
}, 60000);
// ['929807948748832798', '468835415093411861', '1058183358267543552', '549114074273677314'] - 0=Dev Server, 1=Main Server, 2=Throne, 3=Toast's test server
client.user.setPresence(client.config.botPresence);
}, 300000);
if (client.config.botSwitches.registerCommands){
['929807948748832798', '468835415093411861', '1058183358267543552'].forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
client.config.whitelistedServers.forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
}));
@ -30,6 +28,7 @@ client.on('ready', async()=>{
}, 500000);
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
console.log(client.config.botSwitches);
console.log(client.config.whitelistedServers);
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
// Event handler

View File

@ -132,7 +132,9 @@ export interface Config {
embedColorBCA: ColorResolvable,
embedColorXmas: ColorResolvable,
LRSstart: number,
whitelistedServers: Array<string>,
botSwitches: botSwitches,
botPresence: Discord.PresenceData,
eval: Eval,
mainServer: mainServer
}