-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
utils "github.com/betterdiscord/cli/utils" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(uninstallCmd) | ||
} | ||
|
||
var uninstallCmd = &cobra.Command{ | ||
Use: "uninstall <channel>", | ||
Short: "Uninstalls BetterDiscord from your Discord", | ||
Long: "This can uninstall BetterDiscord to multiple versions and paths of Discord at once. Options for channel are: stable, canary, ptb", | ||
ValidArgs: []string{"canary", "stable", "ptb"}, | ||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var releaseChannel = args[0] | ||
var corePath = utils.DiscordPath(releaseChannel) | ||
var indString = "module.exports = require(\"./core.asar\");" | ||
|
||
if err := os.WriteFile(path.Join(corePath, "index.js"), []byte(indString), 0755); err != nil { | ||
fmt.Println("Could not write index.js in discord_desktop_core!") | ||
return | ||
} | ||
|
||
var targetExe = "" | ||
switch releaseChannel { | ||
case "stable": | ||
targetExe = "Discord.exe" | ||
break | ||
case "canary": | ||
targetExe = "DiscordCanary.exe" | ||
break | ||
case "ptb": | ||
targetExe = "DiscordPTB.exe" | ||
break | ||
default: | ||
targetExe = "" | ||
} | ||
|
||
// Kill Discord if it's running | ||
var exe = utils.GetProcessExe(targetExe) | ||
if len(exe) > 0 { | ||
if err := utils.KillProcess(targetExe); err != nil { | ||
fmt.Println("Could not kill Discord") | ||
return | ||
} | ||
} | ||
|
||
// Launch Discord if we killed it | ||
if len(exe) > 0 { | ||
var cmd = exec.Command(exe) | ||
cmd.Start() | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module betterdiscord/cli | ||
module github.com/betterdiscord/cli | ||
|
||
go 1.19 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"betterdiscord/cli/cmd" | ||
"github.com/betterdiscord/cli/cmd" | ||
) | ||
|
||
func main() { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters