aux / discord.net-example Goto Github PK
View Code? Open in Web Editor NEWDiscord.Net Example bots
Discord.Net Example bots
„Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..”
Run into System.InvalidOperationException
while trying to run code.
Program breaks a provider.GetRequiredService<CommandHandler>();
Solution:
Add .AddSingleton<CommandHandler>()
to ConfigureServices
Is there an example of how to use sub commands or choices within slash commands?
Hey,
Unsure if I'm doing something wrong or I am missing something, I cannot get the app to run.
Cloned it and put my token in the config however VS will not parse the YAML file no matter what I do to it.
Here's a log of the error;
System.FormatException
HResult=0x80131537
Message=Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..
Source=Microsoft.Extensions.Configuration.FileExtensions
StackTrace:
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Example.Startup..ctor(String[] args) in C:\Users\Joey\Downloads\Discord.Net-Example-2.0\Discord.Net-Example-2.0\src\Startup.cs:line 20
at Example.Startup.<RunAsync>d__4.MoveNext() in C:\Users\Joey\Downloads\Discord.Net-Example-2.0\Discord.Net-Example-2.0\src\Startup.cs:line 25
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Example.Program.<Main>(String[] args)
Inner Exception 1:
SyntaxErrorException: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI.
Any help maybe?
Hello Auxes,
If you could make a module displaying how to properly get commands and display information about them like their aliases and such that would be awesome.
Thanks,
Hi there,
I just downloaded your example and tried running it, but it breaks with the following error message:
System.FormatException: 'Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..'
The contents of the _config.yml file are:
prefix: !
tokens:
discord: [my bot's token]
Nothing else was changed by me in the code.
Any clues on how to fix this?
Thanks!
~Feng
link is dead in readme.md
i got error ObjectNotFound: User not found. when i try to start command
this is my command code 👍 what I do bad
[Command("info")]
[Summary("sprawdza info")]
[RequireUserPermission(GuildPermission.Administrator)]
public async Task Info(SocketGuildUser user)
{
int maxwarn = 3;
if (File.Exists($"{Context.Guild.Id}maxwarn.XD"))
{
using (StreamReader sr = new StreamReader($"{Context.Guild.Id}maxwarn.XD"))
{
maxwarn = int.Parse(sr.ReadLine());
}
}
int warny = 0;
if (File.Exists($"{user}warn{Context.Guild.Id}.XD"))
{
using (StreamReader sr = new StreamReader($"{user}warn{Context.Guild.Id}.XD"))
{
warny = int.Parse(sr.ReadLine());
}
}
await ReplyAsync($"użytkownik {user} ma {warny} warny ⚠\npamiętaj że po {maxwarn} warnach⚠ jest ban 🚫\nwięc możesz dostać jeszcze {maxwarn-warny} warny⚠");
}
and when I start a bot and write the first command I got the error Object reference not set to an instance of an object
after click continue In visual studio it's work normal
what I do bad
please help
I work on this example
This happens for all commands and I've copied and pasted the code into my project and am wondering where I should look in the code to solve this issue. Of course, I did read where you have the error being output into the Discord channel but really that didn't help me know where it's having an issue getting the command modules.
Of course, since I don't know where the issue is, please tell me what code I should share to resolve this.
Thanks
Not a fatal issue, since it's just the content of an exception, but it could be misleading.
The singleton should be a ThreadLocal<Random>
or maybe a Random with a lock mechanism. Using only one instance on multiple threads will result in getting 0 from every Random call, has happened to me in the past.
Visual Studio 2017 doesn't like that Main
returns a Task
and throws this error during compile. I'm not sure how I should be modifying the Main method since you set it up to return a task.
System.InvalidOperationException HResult=0x80131509 Message=Failed to create "Example.Modules.HelpModule", dependency "IConfigurationRoot" was not found. Source=Discord.Net.Commands StackTrace: at Discord.Commands.ReflectionUtils.GetMember(CommandService commands, IServiceProvider services, Type memberType, TypeInfo ownerType) at Discord.Commands.ReflectionUtils.<>c__DisplayClass2_0
1.b__0(IServiceProvider services)
at Discord.Commands.ReflectionUtils.CreateObject[T](TypeInfo typeInfo, CommandService commands, IServiceProvider services)
at Discord.Commands.Builders.ModuleBuilder.BuildImpl(CommandService service, IServiceProvider services, ModuleInfo parent)
at Discord.Commands.ModuleClassBuilder.d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Discord.Commands.CommandService.d__35.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at DbotTest.Program.d__6.MoveNext() in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 56
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DbotTest.Program.d__4.MoveNext() in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 38
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DbotTest.Program.Main(String[] args) in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 18
This exception was originally thrown at this call stack:
Discord.Commands.ReflectionUtils.GetMember(Discord.Commands.CommandService, System.IServiceProvider, System.Type, System.Reflection.TypeInfo)
Discord.Commands.Builders.ModuleBuilder.BuildImpl(Discord.Commands.CommandService, System.IServiceProvider, Discord.Commands.ModuleInfo)
Discord.Commands.ModuleClassBuilder.BuildAsync(System.Collections.Generic.IEnumerable<System.Reflection.TypeInfo>, Discord.Commands.CommandService, System.IServiceProvider)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
Discord.Commands.CommandService.AddModulesAsync(System.Reflection.Assembly, System.IServiceProvider)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
...
[Call Stack Truncated]
`
I guess this is what I get for doing a "copypasta". All I did was that I made a new cSharp class file and it would scream this at me every time I try to run the bot.
Could you specify the packages I need to add in VS17 for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.