Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Koakuma
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reviath
Koakuma
Commits
2f19b7e2
Commit
2f19b7e2
authored
Feb 25, 2021
by
Reviath
Browse files
Options
Downloads
Patches
Plain Diff
Fixed daily and roulette is ready to MySQL
parent
22530c16
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands/daily.js
+9
-2
9 additions, 2 deletions
commands/daily.js
commands/roulette.js
+32
-9
32 additions, 9 deletions
commands/roulette.js
with
41 additions
and
11 deletions
commands/daily.js
+
9
−
2
View file @
2f19b7e2
...
...
@@ -41,10 +41,17 @@ exports.run = async(client, message, args, connection) => {
connection
.
query
(
sql
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
if
(
cash
.
length
<
1
)
{
let
sql3
=
`INSERT INTO cashes (cash, guildid, userid) VALUES (
${
parseInt
(
money
)
+
parseInt
(
500
)}
,
${
message
.
guild
.
id
}
,
${
message
.
author
.
id
}
)`
connection
.
query
(
sql3
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
}
else
{
let
sql2
=
`UPDATE cashes SET cash ='
${
parseInt
(
money
)
+
parseInt
(
500
)}
' WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
connection
.
query
(
sql2
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
}
};
};
...
...
This diff is collapsed.
Click to expand it.
commands/roulette.js
+
32
−
9
View file @
2f19b7e2
const
Discord
=
require
(
"
discord.js
"
);
const
db
=
require
(
"
quick.db
"
);
module
.
exports
.
run
=
async
(
client
,
message
,
args
)
=>
{
module
.
exports
.
run
=
async
(
client
,
message
,
args
,
connection
)
=>
{
let
user
=
message
.
author
;
function
isOdd
(
num
)
{
if
((
num
%
2
)
==
0
)
return
false
;
...
...
@@ -9,7 +8,20 @@ else if ((num % 2) == 1) return true;
}
let
colour
=
args
[
0
];
let
money
=
args
[
1
];
let
moneydb
=
await
db
.
fetch
(
`Balance_
${
user
.
id
}
`
)
const
cash
=
await
new
Promise
((
resolve
,
reject
)
=>
{
connection
.
query
(
`SELECT cash FROM cashes WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
)
reject
(
err
);
resolve
(
result
);
});
});
var
moneydb
=
""
;
if
(
cash
.
length
<
1
)
{
moneydb
=
0
;
}
else
{
moneydb
=
cash
[
0
].
cash
}
let
random
=
Math
.
floor
(
Math
.
random
()
*
37
);
if
(
money
>
50000
||
money
==
"
all
"
)
{
...
...
@@ -20,7 +32,6 @@ let random = Math.floor(Math.random() * 37);
}
}
let
moneyhelp
=
new
Discord
.
MessageEmbed
()
.
setColor
(
'
BLUE
'
)
.
setDescription
(
`<a:x_:801038779955150888> Specify an amount | .roulette <color> <amount>`
);
...
...
@@ -46,27 +57,39 @@ msg = await message.channel.send(new Discord.MessageEmbed().setColor('BLUE').set
if
(
random
==
0
&&
colour
==
2
)
{
money
*=
15
db
.
add
(
`Balance_
${
user
.
id
}
`
,
money
)
let
sql
=
`UPDATE cashes SET cash ='
${
parseInt
(
money
)
+
parseInt
(
moneydb
)}
' WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
connection
.
query
(
sql
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
let
moneyEmbed1
=
new
Discord
.
MessageEmbed
()
.
setColor
(
"
RED
"
)
.
setDescription
(
`<a:green:802056552672002059> You won
${
money
}
coins\n\nMultiplier: 15x`
);
msg
.
edit
(
moneyEmbed1
)
}
else
if
(
isOdd
(
random
)
&&
colour
==
1
)
{
money
=
parseInt
(
money
*
1.5
)
db
.
add
(
`Balance_
${
user
.
id
}
`
,
money
)
let
sql2
=
`UPDATE cashes SET cash ='
${
parseInt
(
money
)
+
parseInt
(
moneydb
)}
' WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
connection
.
query
(
sql2
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
let
moneyEmbed2
=
new
Discord
.
MessageEmbed
()
.
setColor
(
"
RED
"
)
.
setDescription
(
`<a:red_star:801039507385483306> You won
${
money
}
coins\n\nMultiplier: 1.5x`
);
msg
.
edit
(
moneyEmbed2
)
}
else
if
(
!
isOdd
(
random
)
&&
colour
==
0
)
{
money
=
parseInt
(
money
*
2
)
db
.
add
(
`Balance_
${
user
.
id
}
`
,
money
)
let
sql3
=
`UPDATE cashes SET cash ='
${
parseInt
(
money
)
+
parseInt
(
moneydb
)}
' WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
connection
.
query
(
sql3
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
let
moneyEmbed3
=
new
Discord
.
MessageEmbed
()
.
setColor
(
"
RED
"
)
.
setDescription
(
`<a:black:802055864890425344> You won
${
money
}
coins\n\nMultiplier: 2x`
);
msg
.
edit
(
moneyEmbed3
)
}
else
{
db
.
subtract
(
`Balance_
${
user
.
id
}
`
,
money
)
let
sql
=
`UPDATE cashes SET cash ='
${
parseInt
(
moneydb
)
-
parseInt
(
money
)}
' WHERE guildid ='
${
message
.
guild
.
id
}
' AND userid ='
${
message
.
author
.
id
}
'`
connection
.
query
(
sql
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
});
let
moneyEmbed4
=
new
Discord
.
MessageEmbed
()
.
setColor
(
"
RED
"
)
.
setDescription
(
`<a:x_:801038779955150888> You lost
${
money
}
coins\n\nMultiplier: 0x`
);
...
...
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