Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SL-Projects Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Lasri
SL-Projects Bot
Commits
0d0398cc
Commit
0d0398cc
authored
3 years ago
by
Sofiane Lasri
Browse files
Options
Downloads
Patches
Plain Diff
WebhookClient
parent
fd28b343
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.js
+3
-8
3 additions, 8 deletions
index.js
with
3 additions
and
8 deletions
index.js
+
3
−
8
View file @
0d0398cc
...
...
@@ -242,7 +242,7 @@ recursiveAsyncReadLine(); //we have to actually start our recursion somehow
// BOT DISCORD
////////////////////////////////////////////////////////////////
// require the needed discord.js classes
const
{
Client
,
Intents
,
MessageActionRow
,
MessageButton
}
=
require
(
'
discord.js
'
);
const
{
Client
,
Intents
,
MessageActionRow
,
MessageButton
,
WebhookClient
}
=
require
(
'
discord.js
'
);
const
{
verify
}
=
require
(
'
crypto
'
);
// create a new Discord client
...
...
@@ -461,9 +461,7 @@ async function verifyMcChatWebhook(){
console
.
log
(
"
[
"
+
'
INFO
'
.
yellow
+
"
] Le Webhook du serveur MC est déjà configuré.
"
);
let
mcChatWebhookToken
=
await
botSettings
.
findOne
({
where
:
{
name
:
"
mcChatWebhookToken
"
}
});
if
(
mcChatWebhookToken
){
mcChatWebhook
=
client
.
fetchWebhook
(
mcChatWebhookId
.
value
,
mcChatWebhookToken
.
value
)
.
then
(
webhook
=>
console
.
log
(
"
[
"
+
'
INFO
'
.
yellow
+
"
] Webhook
"
+
webhook
.
name
+
"
trouvé.
"
))
.
catch
(
console
.
error
);
mcChatWebhook
=
new
WebhookClient
({
id
:
mcChatWebhookId
.
value
,
token
:
mcChatWebhookToken
.
value
});
}
else
{
console
.
log
(
"
[
"
+
'
ERREUR
'
.
brightRed
+
"
] Impossible de trouver le token du webhook dans la base de donnée.
"
);
createMcChatWebhook
();
...
...
@@ -487,16 +485,13 @@ async function createMcChatWebhook(){
name
:
"
mcChatWebhookToken
"
,
value
:
webhook
.
token
});
mcChatWebhook
=
client
.
fetchWebhook
(
mcChatWebhookId
.
value
,
mcChatWebhookToken
.
value
)
.
then
(
webhook
=>
console
.
log
(
"
[
"
+
'
INFO
'
.
yellow
+
"
] Webhook
"
+
webhook
.
name
+
"
trouvé.
"
))
.
catch
(
console
.
error
);
mcChatWebhook
=
new
WebhookClient
({
id
:
mcChatWebhookId
.
value
,
token
:
mcChatWebhookToken
.
value
});
console
.
log
(
"
[
"
+
'
INFO
'
.
yellow
+
"
] Le Webhook du serveur MC a été configuré avec succès.
"
);
})
.
catch
(
console
.
error
);
}
function
sendMessageFromMcChat
(
username
,
message
){
console
.
log
(
mcChatWebhook
);
mcChatWebhook
.
send
({
content
:
message
,
username
:
username
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment