mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 21:44:48 +02:00
Make webhook a part of client
This commit is contained in:
+2
-2
@@ -4,6 +4,8 @@ XIAO_TOKEN=
|
|||||||
OWNERS=
|
OWNERS=
|
||||||
XIAO_PREFIX=
|
XIAO_PREFIX=
|
||||||
INVITE=
|
INVITE=
|
||||||
|
XIAO_WEBHOOK_ID=
|
||||||
|
XIAO_WEBHOOK_TOKEN=
|
||||||
|
|
||||||
# Emoji IDs
|
# Emoji IDs
|
||||||
GOLD_FISH_EMOJI_ID=
|
GOLD_FISH_EMOJI_ID=
|
||||||
@@ -33,8 +35,6 @@ TUMBLR_KEY=
|
|||||||
TWITTER_KEY=
|
TWITTER_KEY=
|
||||||
TWITTER_SECRET=
|
TWITTER_SECRET=
|
||||||
WATTPAD_KEY=
|
WATTPAD_KEY=
|
||||||
WEBHOOK_ID=
|
|
||||||
WEBHOOK_TOKEN=
|
|
||||||
WHATANIME_KEY=
|
WHATANIME_KEY=
|
||||||
WORDNIK_KEY=
|
WORDNIK_KEY=
|
||||||
XIAO_GITHUB_REPO_NAME=
|
XIAO_GITHUB_REPO_NAME=
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
|
||||||
const { WEBHOOK_ID, WEBHOOK_TOKEN } = process.env;
|
|
||||||
|
|
||||||
module.exports = class WebhookCommand extends Command {
|
module.exports = class WebhookCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -9,7 +7,7 @@ module.exports = class WebhookCommand extends Command {
|
|||||||
aliases: ['rin', 'rin-say'],
|
aliases: ['rin', 'rin-say'],
|
||||||
group: 'text-edit',
|
group: 'text-edit',
|
||||||
memberName: 'webhook',
|
memberName: 'webhook',
|
||||||
description: 'Posts a message to the webhook defined in your `process.env`.',
|
description: 'Posts a message to the webhook defined in the bot owner\'s `process.env`.',
|
||||||
details: 'Only the bot owner(s) may use this command.',
|
details: 'Only the bot owner(s) may use this command.',
|
||||||
ownerOnly: true,
|
ownerOnly: true,
|
||||||
clientPermissions: ['MANAGE_MESSAGES'],
|
clientPermissions: ['MANAGE_MESSAGES'],
|
||||||
@@ -26,9 +24,7 @@ module.exports = class WebhookCommand extends Command {
|
|||||||
async run(msg, { content }) {
|
async run(msg, { content }) {
|
||||||
try {
|
try {
|
||||||
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
|
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
|
||||||
await request
|
await this.client.webhook.send(content);
|
||||||
.post(`https://discordapp.com/api/webhooks/${WEBHOOK_ID}/${WEBHOOK_TOKEN}`)
|
|
||||||
.send({ content });
|
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "88.1.1",
|
"version": "88.1.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
const { CommandoClient } = require('discord.js-commando');
|
const { CommandoClient } = require('discord.js-commando');
|
||||||
|
const { WebhookClient } = require('discord.js');
|
||||||
const PokemonStore = require('./PokemonStore');
|
const PokemonStore = require('./PokemonStore');
|
||||||
|
const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN } = process.env;
|
||||||
|
|
||||||
module.exports = class XiaoClient extends CommandoClient {
|
module.exports = class XiaoClient extends CommandoClient {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
|
this.webhook = new WebhookClient(XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, { disableEveryone: true });
|
||||||
this.pokemon = new PokemonStore();
|
this.pokemon = new PokemonStore();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user