Skip to content

Commit

Permalink
refacto(#149): remove all eval from codebase
Browse files Browse the repository at this point in the history
for security concerns
  • Loading branch information
barthofu committed Feb 9, 2024
1 parent c8778b9 commit 60baa42
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 53 deletions.
7 changes: 1 addition & 6 deletions src/configs/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ export const generalConfig: GeneralConfigType = {

devs: [], // discord IDs of the devs that are working on the bot (you don't have to put the owner's id here)

eval: {
name: 'bot', // name to trigger the eval command
onlyOwner: false, // restrict the eval command to the owner only (if not, all the devs can trigger it)
},

// define the bot activities (phrases under its name). Types can be: PLAYING, LISTENING, WATCHING, STREAMING
activities: [
{
text: 'discord.js v14',
text: 'discord.js v14 with tscord',
type: 'PLAYING',
},
{
Expand Down
12 changes: 0 additions & 12 deletions src/events/messageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ArgsOf, Client } from 'discordx'

import { generalConfig } from '@/configs'
import { Discord, Guard, On } from '@/decorators'
import { Maintenance } from '@/guards'
import { executeEvalFromMessage, isDev } from '@/utils/functions'

@Discord()
export default class MessageCreateEvent {
Expand All @@ -16,16 +14,6 @@ export default class MessageCreateEvent {
[message]: ArgsOf<'messageCreate'>,
client: Client
) {
// eval command
if (
message.content.startsWith(`\`\`\`${generalConfig.eval.name}`)
&& (
(!generalConfig.eval.onlyOwner && isDev(message.author.id))
|| (generalConfig.eval.onlyOwner && message.author.id === generalConfig.ownerId)
)
)
executeEvalFromMessage(message)

await client.executeCommand(message, false)
}

Expand Down
2 changes: 0 additions & 2 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export default class ReadyEvent {
const client = await resolveDependency(Client)
const activity = generalConfig.activities[this.activityIndex]

activity.text = eval(`new String(\`${activity.text}\`).toString()`)

if (activity.type === 'STREAMING') { // streaming activity
client.user?.setStatus('online')
client.user?.setActivity(activity.text, {
Expand Down
27 changes: 0 additions & 27 deletions src/utils/functions/eval.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './interactions'
export * from './database'
export * from './prefix'
export * from './embeds'
export * from './eval'
export * from './synchronizer'
export * from './converter'
export * from './string'
Expand Down
5 changes: 0 additions & 5 deletions src/utils/types/configs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ interface GeneralConfigType {

devs: string[]

eval: {
name: string
onlyOwner: boolean
}

activities: {
text: string
type: 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM' | 'COMPETING'
Expand Down

0 comments on commit 60baa42

Please sign in to comment.