Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Loïc Bersier
Haha Yes
Commits
c883808c
Commit
c883808c
authored
Jan 15, 2021
by
Loïc Bersier
😎
Browse files
Limit video to 2k and remove the "link" part from the ytphash
Signed-off-by:
loicbersier
<
loic.bersier1@gmail.com
>
parent
e2960d4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
commands/fun/ytp.js
commands/fun/ytp.js
+34
-4
models/ytphash.js
models/ytphash.js
+0
-1
No files found.
commands/fun/ytp.js
View file @
c883808c
...
...
@@ -7,7 +7,7 @@ const attachment = require('../../utils/attachment');
const
downloader
=
require
(
'
../../utils/download
'
);
const
md5File
=
require
(
'
md5-file
'
);
const
ytpHash
=
require
(
'
../../models
'
).
ytpHash
;
const
{
ytpChannel
}
=
require
(
'
../../config.json
'
);
const
MAX_CLIPS
=
20
;
...
...
@@ -224,7 +224,7 @@ class ytpCommand extends Command {
return
message
.
reply
(
'
Video too big.. Not adding.
'
);
}
const
body
=
{
hash
:
hash
,
link
:
url
,
messageID
:
message
.
id
};
const
body
=
{
hash
:
hash
,
messageID
:
message
.
id
};
await
ytpHash
.
create
(
body
);
}
...
...
@@ -236,8 +236,38 @@ class ytpCommand extends Command {
}
});
// (Hopefully) limit video to 2k
if
(
mp4
.
length
>
2000
)
{
let
file
=
mp4
.
sort
((
a
,
b
)
=>
{
let
time1
=
fs
.
statSync
(
`./asset/ytp/userVid/
${
b
}
`
).
ctime
;
let
time2
=
fs
.
statSync
(
`./asset/ytp/userVid/
${
a
}
`
).
ctime
;
if
(
time1
<
time2
)
return
1
;
if
(
time1
>
time2
)
return
-
1
;
return
0
;
}).
slice
(
0
,
1
);
console
.
log
(
file
);
fs
.
unlinkSync
(
`./asset/ytp/userVid/
${
file
[
0
]}
`
);
}
loadingmsg
.
delete
();
return
message
.
reply
(
`Video successfully added to the pool! There is now
${
mp4
.
length
}
videos`
);
message
.
reply
(
`Video successfully added to the pool! There is now
${
mp4
.
length
}
videos`
);
const
Embed
=
this
.
client
.
util
.
embed
()
.
setAuthor
(
message
.
author
.
username
,
message
.
author
.
displayAvatarURL
())
.
addField
(
'
Channel ID
'
,
message
.
channel
.
id
,
true
)
.
addField
(
'
Messsage ID
'
,
message
.
id
,
true
)
.
addField
(
'
Author
'
,
`
${
message
.
author
.
username
}
(
${
message
.
author
.
id
}
)`
,
true
)
.
setTimestamp
();
if
(
message
.
guild
)
{
Embed
.
addField
(
'
Guild
'
,
`
${
message
.
guild
.
name
}
(
${
message
.
guild
.
id
}
)`
,
true
);
Embed
.
addField
(
'
Message link
'
,
`https://discord.com/channels/
${
message
.
guild
.
id
}
/
${
message
.
channel
.
id
}
/
${
message
.
id
}
`
);
}
else
{
Embed
.
addField
(
'
Message link
'
,
`https://discord.com/channels/@me/
${
message
.
channel
.
id
}
/
${
message
.
id
}
`
);
}
let
channel
=
this
.
client
.
channels
.
resolve
(
ytpChannel
);
return
channel
.
send
(
url
,
{
embed
:
Embed
});
});
}
else
{
...
...
@@ -308,7 +338,7 @@ class ytpCommand extends Command {
new
YTPGenerator
().
configurateAndGo
(
options
)
.
then
(()
=>
{
md5File
(
`
${
os
.
tmpdir
()}
/
${
message
.
id
}
_YTP.mp4`
).
then
(
async
hash
=>
{
const
body
=
{
hash
:
hash
,
link
:
'
null
'
,
messageID
:
message
.
id
};
const
body
=
{
hash
:
hash
,
messageID
:
message
.
id
};
await
ytpHash
.
create
(
body
);
});
loadingmsg
.
delete
();
...
...
models/ytphash.js
View file @
c883808c
...
...
@@ -2,7 +2,6 @@
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
const
ytpHash
=
sequelize
.
define
(
'
ytpHash
'
,
{
hash
:
DataTypes
.
STRING
,
link
:
DataTypes
.
STRING
,
messageID
:
DataTypes
.
BIGINT
},
{});
ytpHash
.
associate
=
function
(
models
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment